Results 1 to 8 of 8

Thread: deselect all radio buttons when other one is clicked?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746

    deselect all radio buttons when other one is clicked?

    i put a few radio buttons on a form but when i click more then one they all stay selected. how can i make them deselect when a different one is clicked?

  2. #2
    BG
    Guest
    <form method="POST" action="Whatever">
    <p><input type="radio" value="V1" name="R1"></p>
    <p><input type="radio" value="V2" name="R1"></p>
    <p><input type="radio" value="V3" name="R1"></p>
    <p><input type="radio" value="V4" checked name="R1"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
    </form>




    Make sure all of the radio buttons on the form have the same name, "R1" In this example.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746

    Post

    how do i figure out which one is checked?

  4. #4
    BG
    Guest
    <%
    x = Request.form("R1")
    %>

    x will be the value of the radio button selected
    If the first radio button is selected then x will be
    equal to "V1"

    This is a VBScript Example I'm sure some one here knows the javascript code. I don't off the top of my head.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    how do i use vbscript in a web page? do i just type it in with the HTML and javascripts?

    also if i am using a textarea how can i tell if someone presses return? when i add it on to a url it just string it all together.

  6. #6
    kayoca
    Guest
    Here perhaps this code can bring you an idea how to use mutiply controls with indexes and how to catch the key event of your browser.
    Code:
    <html>
    <head>
    <title></title>
    
    <script language=javascript>
    <!--
    
    function Continue_onclick() {
    
      for ( i=0; 0<rd.length; i++ ) {
        if ( rd[i].checked == true ) {
          alert ( 'You have selected ' + rd[i].value );
          break;
        }
      }
    
    }
    
    function document_onkeydown() {
    
      var sEnter = '13';
      if ( window.event.keyCode.toString() == sEnter ){
        alert ( 'You have pressed the Enter key!' );
      }
    
    }
    
    //-->
    </script>
    
    <script language=javascript for=document event=onkeydown>
    <!--
     document_onkeydown()
    //-->
    </script>
    
    </head>
    <body>
    
    <table id="oTable" name="oTable">
      <tr>
        <td>
        <input type="radio" id="rd" name="rd" value="Red" checked>Red<br>
        <input type="radio" id="rd" name="rd" value="Green">Green<br>
        <input type="radio" id="rd" name="rd" value="Blue">Blue<br>
        <input type="radio" id="rd" name="rd" value="Black">Black
        </td>
      </tr>
      <tr>
        <td>
        <input type="button" value="Button" id="Continue" name="Continue" LANGUAGE=javascript onclick="return Continue_onclick()">
        </td>
      </tr>
    </table>
    
    </body>
    </html>

  7. #7
    Lively Member Base's Avatar
    Join Date
    Aug 2001
    Location
    The Netherlands
    Posts
    65
    Ok this is the client but how do I get these values at the server side?

    Thanks
    Ok

  8. #8
    kayoca
    Guest

    Cool

    You can use Request("rd") to get the values. But i think you need to split up the string.

Posting Permissions

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



Click Here to Expand Forum to Full Width