...

View Full Version : Checkbox question



SteveH
08-21-2008, 08:06 PM
Hello

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:


<table><tr><td>
<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>
</td></tr></table>

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.

Thanks.

Steve

Philip M
08-21-2008, 09: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';
window.close();
return false;
}
</script>


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

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

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

Many thanks for your help.

Steve

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

Cheers

Steve



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum