/ Published in: JavaScript
/* How to use */
var prima = getCheckedValue(document.forms["myForm"].elements['myRadio'])
var prima = getCheckedValue(document.forms["myForm"].elements['myRadio'])
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; }