Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Checkbox question

    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:

    Code:
    <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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    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:-

    Code:
    <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

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    That looks very promising, Philip M.

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

    Many thanks for your help.

    Steve

  • #4
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    That works fine, Philip. Hats off to you!

    Cheers

    Steve


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •