Hi guys, just started using rails and is trying to implementing the present html with some rails... However i met this problem when i am trying to port over some php code in html to rails and i cant find any method to successful convert the php codes. Below is a feature i tried to implement in rails way: there are 2 buttons on the html. Besides these 2 buttons is an infobox. So, whenever one of the buttons is pressed, the infobox have to show the respective information assigned to each button. At any one time, only one button can be pressed and the infobox have to change the information displayed inside it accordingly and immediately. Here is the code i did and not sure wat''s wrong: <fieldset> <legend>button info</legend> <div id="InfoBox"> <h2>Info</h2> <div id="button1"> <strong>Button1</strong> some text here </div> <div id="button2"> <strong>Button2</strong> some text here </div> </div> <label for="buttons">2 buttons</label> <input type="radio" id="button1" onclick="Effect.Appear(''button1'')">Button 1 <input type="radio" id="button2" onclick="Effect.Appear(''button2'')">Button 2 </fieldset> Thanks for any help anyone can provide me. -- Posted via http://www.ruby-forum.com/.
bao lee wrote:> Hi guys, just started using rails and is trying to implementing the > present html with some rails...Anyone can help???? -- Posted via http://www.ruby-forum.com/.
bao lee wrote:> Hi guys, just started using rails and is trying to implementing the > present html with some rails...<snip> Firstly, you''ve given the buttons the same IDs as the divs they''re referring to. That can''t work. Secondly, you''ve not taken care of making anything disappear. Thirdly, Effect.Appear() et al need to be called as constructors. Finally, although it''s understandable that you aren''t aware of it, the correct list for this question would be rails-spinoffs@lists.rubyonrails.org, because it''s a scriptaculous problem rather than about Rails itself. Oh, the code? Try this: :-) <fieldset> <legend>button info</legend> <h2>Info</h2> <div id="InfoBox" style=''position: relative; height: 3em''> <div id="button1" style=''display: none;position: absolute;top:0px''> <strong>Button1</strong> some text here </div> <div id="button2" style=''position:absolute;top:0px;''> <strong>Button2</strong> some text here </div> </div> <label for="buttons">2 buttons</label> <input type="radio" name=''foo'' onclick="new Effect.Appear(''button1'');new Effect.Fade(''button2'');">Button 1 <input type="radio" name=''foo'' onclick="new Effect.Fade(''button1'');new Effect.Appear(''button2'');">Button 2 </fieldset> Tested to be fine in Firefox, although I''ve jiggled your tree a bit, so to speak. -- Alex
Alex Young wrote:> bao lee wrote: >> Hi guys, just started using rails and is trying to implementing the >> present html with some rails... > <snip> > > Firstly, you''ve given the buttons the same IDs as the divs they''re > referring to. That can''t work. Secondly, you''ve not taken care of > making anything disappear. Thirdly, Effect.Appear() et al need to be > called as constructors. Finally, although it''s understandable that you > aren''t aware of it, the correct list for this question would be > rails-spinoffs@lists.rubyonrails.org, because it''s a scriptaculous > problem rather than about Rails itself. >Oh sorry about that... didnt know that the nature of the problem is not rails itself... thanks for all your trouble. -- Posted via http://www.ruby-forum.com/.