Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 JavaScript: Get and set radio buttons with Javascript Jump to:  
Category: >> JavaScript >> Get and set radio buttons with Javascript Bookmark and Share

<< lastnext >>

Snippet Name: Get and set radio buttons with Javascript

Description: Easy functions to get and set radio buttons with Javascript. Super handy!

Comment: (none)

Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: February 27th, 2009

// The getRadio(radio) function returns the 
// value of the active radio button. 
 
FUNCTION getRadio(radio){
 
         // Parameters:
            // "radio" is a radio button object, <formname>.<radiogroup>
 
         // Behavior:
            // The value of the active radio button is returned to the caller
 
   FOR(i=0; i<radio.length; i++){
      IF(radio[i].checked){
         RETURN(radio[i].value);
         BREAK;
      }
   }
}
 
 
// The setRadio(radio, value) function sets the 
// active radio button that matches the value.
 
FUNCTION setRadio(radio, value){
 
         // Parameters:
            // "radio" is a radio button object, <formname>.<radiogroup>
            // "value" is the radio button to activate
 
         // Behavior:
            // Sets the active radio button
 
   FOR(i=0; i<radio.length; i++){
      IF(radio[i].value == value){
         radio[i].checked = TRUE;
      } ELSE {
         radio[i].checked = FALSE;
      }
   }
 
}
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 67 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?