Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox undefined problem. URGENT!!!

Status
Not open for further replies.

Albuckj2

Programmer
Jan 7, 2003
68
0
0
GB
I have a problem with checkboxes.
I have a JavaScript function which checks whether any rows of a table have been checked (each row has a checkbox). If no rows are checked, are the user has requested to delete some checked rows, then a prompt is made to the user to tell them they haven't checked any.

This works fine 99% of the time, EXCEPT where I only have 1 row in the table. In that case, it can't even see the checkbox. The debug line below produces an error which says that "document.addToPort.epic.0.checked is nul or nor an object".

alert("document.addToPort.epic[0].checked is " + document.addToPort.epic[0].checked);

Also, it is assigning document.addToPort.epic.length to "undefined", when it should be 1.

The exact code works fine where there is more than 1 record. So what's going on?

I am using IE 6.0

cheers for any help.
 
Post the URL, or the relevant code so we can see and try to help...

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
this is because when there is only one element named "epic", you cannot use array notation (epic[0]) to access it. you must simply use "epic"



=========================================================
while (!succeed) try();
-jeff
 
Thanks jemminger, that's just what the problem is. Never knew that!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top