codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  checkbox verification..headache!!  mykstor at 01:28 on Tuesday, December 01, 2009
 

I'm really TRYING to learn the most basic stuff in Javascript, but seem to spend hours and hours on each tiny thing. This is so minor, you'll laugh at me. This is just a box that has to be checked before next page will open. I've tried this with checkbox value 0 / 1 and true / false. Makes no difference.

Here's my script. What the $&@% is wrong with it? Nothing happens. I can't write the simplest!
My thanks in advance to anyone who can take a second to help! Mykstor, Los Angeles.

<scr r ipt language=javascript>
<!--

function validate(chk)


if (chk.checked !== 1);
{

alert("You haven't checked the AGREEMENT box. Please READ the AGREEMENT, then check the box.");

}
else
{

document.open('stories1.html');

}

-->
</scr r ipt>

---------------

my call:

<form>
<input type=checkbox name=chk><font color="#FF0000"> CHECK HERE  </font>
<p><input type=button value="check" onClick="return validate(chk);"></p>
</form>

  Re: checkbox verification..headache!!  HW9x9 at 01:35 on Saturday, December 05, 2009
 

<sc rr ipt language="javascript">
function validate(){
if (x.chk.checked){
alert("allright");
}else{
alert("You haven't checked the AGREEMENT box. Please READ the AGREEMENT, then check the box.");
}
}
</sc rr ipt>

---------------

<form name="x" onSubmit="validate();">
<INPUT TYPE="checkbox" name="chk" ><font color="#FF0000"> CHECK HERE </font>
<p><INPUT TYPE="submit" value="check" ></p>
</form>


So a function starts with a"{" and ends with "}", a form must have a name.

<Added>

see below

  Re: checkbox verification..headache!!  HW9x9 at 01:38 on Saturday, December 05, 2009
 

script language="javascript"

function validate(){
if (x.chk.checked){

alert("allright");


}else{

alert("You haven't checked the AGREEMENT box. Please READ the AGREEMENT, then check the box.");

}

}
/script

---------------

form name="x"onSubmit="validate();"
INPUT TYPE="checkbox" name="chk"
INPUT TYPE="submit" value="check"
/form

a function starts with "{", end with "}", form has a name

  Re: checkbox verification..headache!!  mykstor at 02:58 on Saturday, December 05, 2009
 

Thank you so much!!!

Mike

  Re: checkbox verification..headache!!  amery buck at 04:22 on Thursday, May 27, 2010
 

Beautiful blog with great informational content. Mostly certifications related and headache related topics are really very good. 1z0-051 dumps, NS0-163 dumps and 646-985 dumps are also good topics. Thanks for this great sharing.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Join Free Webinar: How Cisco’s Pulse uses Lucene/Solr to put Social Networks to Work
•  Changing marquee data
•  Vertical and Horizontal Image Scroller
•  needing an auto-populating form fields or drop down
•  needing an auto-populating form fields or drop down
•  document.getElementByID and IE
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: How do i create somethign like this?:
•  Re: $_GET not working


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010