SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form manipulation

    Here is my dilemna. I have two radio buttons that are linked with the name radio_one.

    If you check the first radio button it's value is value1.

    The second radio button's value needs to be dynamic based on what you select from a pulldown next to it. How can this be accomplished with javascript??
    Feel free to e-mail me any questions, jobs rants, whatever...

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this?

    <select onChange="(document.getElementById("RadioButtonTwoId")).value = this.selectindex">
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Form manipulation

    Originally posted by nollieflip
    Here is my dilemna. I have two radio buttons that are linked with the name radio_one.

    If you check the first radio button it's value is value1.

    The second radio button's value needs to be dynamic based on what you select from a pulldown next to it. How can this be accomplished with javascript??

    Here's some code to start you off:
    Code:
    <html>
    <head>
    <script language="javascript" type="text/javascript">
    function changeRadio(selection, radioButton) {
     var selIndex = selection.options[selection.selectedIndex].value;
     radioButton.value = selIndex;
     return true;
    }
    </script>
    </head>
    <body>
    <form name="form1" method="post" action="#">
    <input type="radio" name="radio_one" value="value1">
    <br />
    <select name="select_one" onchange="return changeRadio(this, document.forms['form1'].elements['radio_one[1]']);">
    <option value="value2">Value 2</option>
    <option value="value3">Value 3</option>
    </select>
    <input type="radio" name="radio_one" value="">
    </form>
    </body>
    </html>
    Code is not tested but should work.

    --Vinnie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •