View Single Post
Old 03-23-2009, 06:15 PM   #1 (permalink)
oldskool
oldskool's Avatar
 
Electrical Systems Design

Join Date: Jun 2008

Location: Maine, USA

Posts: 1,646

oldskool has a spectacular aura aboutoldskool has a spectacular aura about

Default Javascript function problem

I am trying to get this code to work such that when you click the button, a pop-up box tells you that you have to check the checkbox first. There isn't actually a destination page yet, I am trying to just get the code to work right for the above to occur.

Can anyone tell me what is wrong with my code ? Thanks in advance for any help.

Code:
<html>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Check box practice HTML</title>

<meta http-equiv="content-type" content="text/html;
     charset=iso-8859-1" />


....I removed this part of the HTML for brevity.....

Do you agree to the terms above ? <br />

If so, please check the checkbox below.<h3>

<br />
<br />

<script type="text/javascript">
/* <![CDATA[ */
//code written by Eric Maddan

 


function chkBoxselected()  {
   if (document.terms.chkBox.checked == false)   {
     
      alert (' You didn't click the checkbox to confirm the rules listed above !');
      return false;
      }
   else
      {
      return true;
      }

}
 

/* ]]> */


</form>
</script>
</head>

<body>
<script type="text/javascript">
/* <![CDATA[ */



/* ]]> */

</script>


<form name="terms">
<input type="checkbox" name="chkBox" />  I accept the terms and conditions<br /><br />
<input type="button" name="close" value="Enter Site" size="75" 
    onclick="function chkBoxselected()";>

</form>
    
    

</body>
</html>

__________________
  • Operating system(s) : Windows 7 Home Premium x64 | Ubuntu 9.10
  • CPU : Pentium Dual-Core E5200 @ 2.50GHz /Socket 775 LGA
  • Memory: 2X 2GB DDR2 SDRAM
  • Hard drive: 640 GB Western Digital Caviar Blue 7200rpm WD6400AAKS-75
  • Motherboard : Dell 0U880P
  • Video: nVidia GeGorce 8400GS
  • Chipset : Intel G41

<<<<< If you found anything I said helpful, please click the or under my avatar
oldskool is offline