Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I update radio buttons based on a selection from a pull down menu and vice ver

    I need a little help on this script. At the moment the dropdown menu's change the radio buttons, but the radio buttons does not change the menu. How can I make this work both ways??

    Code:
    <html>
    <head>
    	<title>Select Radio</title>
    </head>
    
    <body>
    <form name="my_form">
    <input type="radio" name="r" checked>
    <input type="radio" name="r">
    <input type="radio" name="r">
    <input type="radio" name="r">
    <br>
    <select onchange="this.form.r[this.options
    [this.selectedIndex].value].checked=true"> 
    	<option value="0">0</option>
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>			
    </select>
    
    </form>
    
    </body>
    </html>
    Thanks in advance!

  • #2
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <body>
    <form name="my_form">
    <input type="radio" value="0" name="r" checked onclick="this.form.s[this.value].selected=true">
    <input type="radio" value="1" name="r"onclick="this.form.s[this.value].selected=true">
    <input type="radio" value="2" name="r"onclick="this.form.s[this.value].selected=true">
    <input type="radio" value="3" name="r"onclick="this.form.s[this.value].selected=true">
    <br><br>
    <select name="s" onchange="this.form.r[this.options
    [this.selectedIndex].value].checked=true"> 
    	<option value="0">0</option>
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>			
    </select>
    
    </form>
    
    </body>
    </html>
    <JPM />

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Simpler version:
    Code:
    <input type="radio" value="0" name="r" checked onclick="this.form.s.selectedIndex=this.value">
    <input type="radio" value="1" name="r"onclick="this.form.s.selectedIndex=this.value">
    <input type="radio" value="2" name="r"onclick="this.form.s.selectedIndex=this.value">
    <input type="radio" value="3" name="r"onclick="this.form.s.selectedIndex=this.value">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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