Posted By

ib_designer on 01/26/07


Tagged

Value radio


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


fn. get radio button value


 / Published in: JavaScript
 

/* How to use */ var prima = getCheckedValue(document.forms["myForm"].elements['myRadio'])

  1. function getCheckedValue(radioObj) {
  2. if(!radioObj)
  3. return "";
  4. var radioLength = radioObj.length;
  5. if(radioLength == undefined)
  6. if(radioObj.checked)
  7. return radioObj.value;
  8. else
  9. return "";
  10. for(var i = 0; i < radioLength; i++) {
  11. if(radioObj[i].checked) {
  12. return radioObj[i].value;
  13. }
  14. }
  15. return "";
  16. }

Report this snippet  

You need to login to post a comment.