Loading ...
Sorry, an error occurred while loading the content.

javascript- radio button

Expand Messages
  • e111982
    hi. i have a radio button which is checked and want it to be enchecked when the page is refreshed. can you help me? thanks...
    Message 1 of 2 , Nov 10, 2004
    • 0 Attachment
      hi.
      i have a radio button which is checked and want it to be enchecked
      when the page is refreshed. can you help me?
      thanks...
    • Darwin Valencia
      //####### this is if it is only a single radio button in the form ## Untitled function
      Message 2 of 2 , Nov 11, 2004
      • 0 Attachment
        //####### this is if it is only a single radio button in the form ##
        <html>
        <head>
        <title>Untitled</title>
        <script language="Javascript">
        function removeCheck()
        {
        var radio_button = document.myForm.myRadio

        if( radio_button.checked = true )
        radio_button.checked = false

        }
        </script>
        </head>
        <body onLoad=removeCheck()>

        <form name="myForm">
        <input type="radio" name="myRadio" value="value1" checked>VALUE 1<BR>
        </form>

        </body>
        </html>

        //##### this is if u have multiple radio buttons ###
        <html>
        <head>
        <title>Untitled</title>
        <script language="Javascript">
        function removeCheck()
        {
        var radio_button = document.myForm.myRadio

        // determine how many radio buttons are there
        var no_buttons = radio_button.length

        // begin going through all the button and find the checked one
        for(var ctr=0; ctr<no_buttons; ctr++)
        {
        //find the checked button and unchecked it
        if( radio_button[ctr].checked = true )
        radio_button[ctr].checked = false
        }

        }
        </script>
        </head>
        <body onLoad=removeCheck()>

        <form name="myForm">
        <input type="radio" name="myRadio" value="value1" checked>VALUE 1<BR>
        <input type="radio" name="myRadio" value="value2">VALUE 2<BR>
        <input type="radio" name="myRadio" value="value3">VALUE 4<BR>

        </form>

        </body>
        </html>

        /////###############
        how this would help
      Your message has been successfully submitted and would be delivered to recipients shortly.