Radio Button Question with Javascript
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Radio Button Question with Javascript

From: <amerar@iwc.net>
Date: Thu Jan 26 2006 - 16:50:45 CET

Hi All,

I am using this code to dynamically check is a radio button was checked
on the page. This worked great, if there is more then 1 button in the
group, but fails if there is only 1 button in the group......

Can anyone help debug? I'm stumped.....

function valButton(btn) {;
var cnt = -1;;
for (var i=btn.length-1; i > -1; i--) {;
   if (btn[i].checked) {cnt = i; i = -1;};
   };
if (cnt > -1) {return btn[cnt].value;};
else {return null;};
};

Thanks,
Received on Tue Feb 7 21:23:53 2006