Jump to content

Dynamic Forms


afrojojo

Recommended Posts

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
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.