checking if checkbox is set to true

P

Peter

Hello I'm trying to create a script that checks to see if any of the
checkboxes are set on a onSubmit.

For some reason it never returns a value of true of false.

here's the script:
<script language="javascript">
function confirmCancel(ticketcnt)
{
var retVal = false;

for (x = 0; x <= ticketcnt; x++)
{
var cancel_fld = "cancel" + x;

if (document.getElementById.(cancel_fld).checked == true)
{
retVal = true;
}
}

return retVal;
}
</script>

here's how i call it

<form name="CancelCMTicket_frm" action="cancelCMRec.php" method="post"
onSubmit="return confirmCancel('3')">

The last line return retVal. retVal variable never gets set.

I'm stuck on this one, can anyone give any advice.

Thanks
Peter
 
A

Alvaro G. Vicario

*** Peter escribió/wrote (Wed, 23 Aug 2006 13:14:25 -0400):
if (document.getElementById.(cancel_fld).checked == true)

getElementById() is not an attribute but a method. Remove the dot before
the parenthesis. Also, the "== true" comparison is redundant (not a
problem, though).

Do you use Firefox's JavaScript console? Using non-existent attributes
always raises an error.
 
P

Peter

awesome thank you.

I missed the dot, dont' know why I put in there.
I should try using Firefox

Thanks again
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top