Add drop down options after radio button click

Discussion in 'Javascript' started by hust6, Jun 13, 2006.

  1. hust6

    hust6 Guest

    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!
     
    hust6, Jun 13, 2006
    #1
    1. Advertising

  2. hust6

    Jim Guest

    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>
     
    Jim, Jun 14, 2006
    #2
    1. Advertising

  3. hust6

    hust6 Guest

    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>
     
    hust6, Jun 14, 2006
    #3
  4. hust6

    the DtTvB Guest

    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]"
     
    the DtTvB, Jun 14, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    817
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,072
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    547
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    317
  5. Replies:
    0
    Views:
    193
Loading...

Share This Page