afrojojo Posted January 10, 2007 Share Posted January 10, 2007 I would appreciate it if one of you lads could give me some javascript code.I would like to have a form that starts out with only two radio buttons. If one is checked, two text box fields appear below it. If the other one is checked, two different text boxes appear below.Thanks Quote Link to comment Share on other sites More sharing options...
weknowtheworld Posted January 10, 2007 Share Posted January 10, 2007 Use have to use txtboxname.style.display='hidden' and txtboxname.style.display='visible' in javascript onclick() in radio button.. Quote Link to comment Share on other sites More sharing options...
afrojojo Posted January 10, 2007 Author Share Posted January 10, 2007 [quote author=weknowtheworld link=topic=121740.msg501121#msg501121 date=1168409781]Use have to use txtboxname.style.display='hidden' and txtboxname.style.display='visible' in javascript onclick() in radio button..[/quote]Thanks, but could you give me an example with all the code together? Quote Link to comment Share on other sites More sharing options...
nogray Posted January 12, 2007 Share Posted January 12, 2007 this should do what you need.[code]<script language="javascript"> function show_form(div_id){ document.getElementById('form1').style.display = "none"; document.getElementById('form2').style.display = "none"; document.getElementById(div_id).style.display = ""; }</script><input type="radio" onclick="show_form('form1')" name="form" /> Form1<br /><input type="radio" onclick="show_form('form2')" name="form" /> Form2<br /><div id="form1" style="display:none;"> <input type="text" value="Form 1 fields" /></div><div id="form2" style="display:none;"> <input type="text" value="Form 2 fields" /></div>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.