...

View Full Version : Help on Checkbox and OnClick



Aileen
07-10-2002, 05:37 AM
This maybe easy, but I'm a complete novice at javascript. How do I write a script if a checkbox is clicked/marked, it should open A.html, otherwise if checkbox is left unchecked open B.html upon hitting 'submit' button? I only have one checkbox in my form. Thank you in advance for taking the time to help.

adios
07-10-2002, 06:10 AM
<html>
<head>
</head>
<body>
<form action="B.html" onsubmit="alert('Form action is ' + this.action);return false">
<input type="checkbox" onclick="this.form.action=(this.checked)?'A.html':'B.html'">
Go To A.html<br>
<input type="submit">
</form>
</body>
</html>

The onsubmit is just for illustration.

Aileen
07-10-2002, 07:01 AM
Thanks for your code. I'm sorry if I wasn't clear enough with my inquiry . But, I would like something that would load an html page (called A.html) if a checkbox is checked or load B.html page if the checkbox field is left blank as opposed to opening a pop-up message box when the submit button is hit. Thanks.

Cloudski
07-10-2002, 07:22 AM
I would like something that would load an html page (called A.html) if a checkbox is checked or load B.html page if the checkbox field is left blank as opposed to opening a pop-up message box when the submit button is hit.


Just remove the onsubmit part. He said himself it was just for show....

Aileen
07-10-2002, 07:49 PM
Hey, thanks. I didn't see his/her last line of message re: onsubmit. I'll remove that part. THanks again to all who responded.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum