HighDots Forums  

javascript returning undefined on length

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss javascript returning undefined on length in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marshall Dudley
 
Posts: n/a

Default javascript returning undefined on length - 09-29-2005 , 11:44 AM






I am wanting to deteremine which radio button is selected on a form and
am using:

//alert(document.CC.Ecom_Payment_Card_Type.length)
for (var i=0;i<document.CC.Ecom_Payment_Card_Type.length;i+ +) {
if (document.CC.Ecom_Payment_Card_Type[i].checked) {
var CardType =
document.CC.Ecom_Payment_Card_Type[i].value
}
}


This works fine if there are 2 or more radio buttons, but if there is
only one, it fails. The alert if I uncomment it says that the length is
undefined, when it should be 1. Anyone know what the problem is and how
I can get around it?

Marshall


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.