View Full Version : Checkbox question

08-21-2008, 07:06 PM

I have a Web page which will eventually be put onto a CD. There is a disclaimer at the front and the visitor ticks an 'I agree' or 'I disagree' checkbox.

If the 'I agree' checkbox is ticked, the visitor is redirected to the next page.

At the moment, if the 'I disagree' is checked, nothing happens.

This is the code I have:

<label><input type="checkbox" name="CHKBOX_1" value="1" unchecked="unchecked"><font size="2" face="tahoma">I do <b>not</b> accept the terms and conditions</font></label>
</td><td><label><input type="checkbox" name="CHKBOX_2" value="2" onclick = "redirect()" unchecked="unchecked"><font size="2" face="tahoma">I <b>do</b> accept the terms and conditions</font></label>

Is there a way, in JavaScript, to exit the user back onto his desktop (that is, out of the CD altogether) if he clicks 'I disagree'?

Thanks for any advice.



Philip M
08-21-2008, 08:35 PM
You need to have a method of validating that one choice or the other has been clicked. Better perhaps to have two buttons which compels the user to click on one or the other to proceed:-

<input type = "button" id = "but1" value = "I DO accept the terms and conditions" onclick = "redirect()">
<input type = "button" id = "but2" value = "I DO NOT accept the terms and conditions" onclick = "cancel()">

<script type = "text/javascript">

function redirect() {
alert ("You have accepted the terms and conditions so you are being redirected to the next page ")
window.location = "newpage.html";
function cancel() {
alert ("You have NOT accepted the terms and conditions so the program will now exit ");
window.opener = 'x';
return false;

It is your responsibility to die() if necessary….. - PHP Manual

08-21-2008, 08:48 PM
That looks very promising, Philip M.

Let me try it and I'll post back (probably tomorrow).

Many thanks for your help.


08-22-2008, 03:28 PM
That works fine, Philip. Hats off to you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum