Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Add drop down options after radio button click

Reply
Thread Tools

Add drop down options after radio button click

 
 
hust6
Guest
Posts: n/a
 
      06-13-2006
I created a form using html, but am having trouble with one issue.

If I user clicks "no" on one of my radio buttons, I want a drop down
selection to appear next to it to display several "reasons" as to why
they chose "no".

How can I implement this?

Thanks in advance for the help!

 
Reply With Quote
 
 
 
 
Jim
Guest
Posts: n/a
 
      06-14-2006
Here you go :
<body >
<form name="myform" action="" method="get">
Would You Buy Our Product?
<input type="radio" name="purchase" value="yes"
onClick="document.forms[0].elements['reasons'].style.display='none'"/>
Yes
<input type="radio" name="purchase" value="no"
onClick="document.forms[0].elements['reasons'].style.display='inline'"/>
No
<select name="reasons" style="display:none" >
<option value="" selected>Please Tell Us Why You Answered 'No'</option>
<option value="not interested">Not Interested</option>
<option value="haveonealready">Have one Already</option>
<option value="tooexpensive">Too Expensive</option>
</select>
<br/><br/>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</form>
</body>

 
Reply With Quote
 
 
 
 
hust6
Guest
Posts: n/a
 
      06-14-2006
That is exactly what I was looking for.

Thanks a ton!







Jim wrote:
> Here you go :
> <body >
> <form name="myform" action="" method="get">
> Would You Buy Our Product?
> <input type="radio" name="purchase" value="yes"
> onClick="document.forms[0].elements['reasons'].style.display='none'"/>
> Yes
> <input type="radio" name="purchase" value="no"
> onClick="document.forms[0].elements['reasons'].style.display='inline'"/>
> No
> <select name="reasons" style="display:none" >
> <option value="" selected>Please Tell Us Why You Answered 'No'</option>
> <option value="not interested">Not Interested</option>
> <option value="haveonealready">Have one Already</option>
> <option value="tooexpensive">Too Expensive</option>
> </select>
> <br/><br/>
> <input type="submit" value="Submit"/>
> <input type="reset" value="Reset"/>
> </form>
> </body>


 
Reply With Quote
 
the DtTvB
Guest
Posts: n/a
 
      06-14-2006
Jim wrote:
> <input type="radio" name="purchase" value="yes"
> onClick="document.forms[0].elements['reasons'].style.display='none'"/>


If there are any forms before that form, that script won't work.
Try "this.form" instead of "document.forms[0]"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Enable second drop down after first drop down is selected teser3@hotmail.com Javascript 0 01-28-2009 12:59 AM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57