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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox onclick validation

Status
Not open for further replies.

gwilym40

Programmer
May 2, 2002
31
GB
I have a asp form with a checkbox defined as below

<font face=&quot;Arial&quot;>Copy from Applicant details<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;applicant_details&quot; value=&quot;YES&quot; onclick=&quot;return passvalues();&quot; SIZE=&quot;30&quot;><font face=&quot;Arial&quot; color=red>

The function passvalues() is defined as

function passvalues()
{
If (document.HouseApp2.applicant_details.checked)
{
alert(&quot;yes&quot;)
}
alert(&quot;no&quot;)
}

When running it I keep getting an error saying object expected line 12 (which is the If statement line)

any ideas much appreciated

Tony
 
firstly, the if statement should not be using a capital I
secondly the alert statements need semicolons after them
thirdly you will need a return statement after alerrt(&quot;yes&quot;)
or it will display both messages when the box is checked.

try this code:
function passvalues()
{
if(document.HouseApp2.applicant_details.checked)
{
alert(&quot;yes&quot;);
return;
}
alert(&quot;no&quot;);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top