Raised This Month: $ Target: $400
 0% 

JavaScript help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Rirre
Veteran Member
Join Date: Nov 2006
Old 12-17-2010 , 21:43   Re: JavaScript help
Reply With Quote #6

Quote:
Originally Posted by joaquimandrade View Post
The problem with your code is that by clicking the image your are submitting the form and the action of your code to change the page gets overriden.
Code:
<html>
<head>
<script language=javascript>
function validate(chk){

  if (chk.checked == 1)
    window.location='newpage.php';    
  else
    alert("You have to agree");
}
</script>
</head>

<body>
    <form onsubmit="validate(chk1);return false">
        <input type='checkbox' name='chk1' /> Agree<br />
        <input type='image' src='images/continue.jpg' align='right' />
    </form>
</body>
</html>
Thank you
Rirre is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode