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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Ensure they click button for privacy statement

    Hi everyone,
    Would you provide the solution for this case?
    Background:
    I would link to create 5 checkboxes and 1 button for the users in the account registration process. If all checkboxes checked, they will refer to other page, otherwise, the alert will be existed.

    Thanks for your help!!


    My Current Coding in Post#3
    Last edited by twinkle726; 10-16-2012 at 04:07 AM. Reason: Remind people that I have provided the current coding

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,073
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Arrow

    Quote Originally Posted by twinkle726 View Post
    Hi everyone,
    Would you provide the solution for this case?
    Background:
    I would link to create 5 checkboxes and 1 button for the users in the account registration process. If all checkboxes checked, they will refer to other page, otherwise, the alert will be existed.

    Thanks for your help!!
    The forum is not a programming service.

    Please provide what you have developed to this point, ie: Show some code.

    We will be happy to comment on your attempt.

  • Users who have thanked jmrker for this post:

    twinkle726 (10-16-2012)

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry, I am the beginner of the program. Here is my code. I don't know what's wrong with it. Please comment on it. Thanks very much!
    <script type="text/javascript" language="JavaScript">
    <!--
    function checkCheckBoxes() {
    if (
    CHECKBOX_1.checked == true &&
    CHECKBOX_2.checked == true &&
    CHECKBOX_3.checked == true &&
    CHECKBOX_4.checked == true &&
    CHECKBOX_5.checked == true)
    {
    window.open(www.yahoo.com.hk=0', target='_parent') ;
    } else {
    alert ('You didn\'t choose all checkboxes!')
    }
    }
    //-->
    </script>
    <body>
    <div><input type="CHECKBOX" name="CHECKBOX_1" value="1"> statement 1</div>
    <br/>
    <div><input type="CHECKBOX" name="CHECKBOX_2" value="2"> statement 2</div>
    <br/>
    <div><input type="CHECKBOX" name="CHECKBOX_3" value="3"> statement 3</div>
    <br/>
    <div><input type="CHECKBOX" name="CHECKBOX_4" value="4"> statement 4</div>
    <br/>
    <div><input type="CHECKBOX" name="CHECKBOX_5" value="5"> statement 5</div>
    <br/>
    <button class="btn-20-prpl "onclick="checkCheckBoxes()"" value=""><span> Accept</span></button>
    <br/>

    <button class="btn-20-prpl" onclick="window.open('www.gooogle.com', target='_parent')" value=""><span> Not Accept</span></button>

  • #4
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,073
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    You have a number of syntax errors in your last post. Check the error console if you are using the FF or Chrome browsers.

    language="javascript" is archaic and no longer needed.

    I'm not always sure what it is that you are trying to accomplish here,
    but this is my guess as to your problem solution.

    Note, you should use [ code] and [ /code] tags (without the spaces)
    around your scripts to make it easier for forum members to read, copy, test, etc.

    Code:
    <html>
    <head>
    <title></title>
    <script type="text/javascript">
    function checkCheckBoxes() {
      var sel = document.getElementById('cbArea').getElementsByTagName('input');
      var allChecked = true;
      for (var i=0; i<sel.length; i++) {
        if (!sel[i].checked) { allChecked = false; }
      }
      if (allChecked == true) {
    //    window.open('www.yahoo.com.hk=0', target='_parent');  // syntax off ???
        window.location.href = 'http://ww.yahoo.com';
      } else {
        alert ('You didn\'t choose all checkboxes!')
      }
    }
    </script>
    </head>
    <body>
    <div id="cbArea">
     <div><input type="CHECKBOX" name="CHECKBOX_1" value="1"> statement 1</div> <br/>
     <div><input type="CHECKBOX" name="CHECKBOX_2" value="2"> statement 2</div> <br/>
     <div><input type="CHECKBOX" name="CHECKBOX_3" value="3"> statement 3</div> <br/>
     <div><input type="CHECKBOX" name="CHECKBOX_4" value="4"> statement 4</div> <br/>
     <div><input type="CHECKBOX" name="CHECKBOX_5" value="5"> statement 5</div> <br/>
    </div>
    <button class="btn-20-prpl" onclick="checkCheckBoxes()"> Accept Yahoo</button>
    <button class="btn-20-prpl" onclick="window.location.href='http://www.gooogle.com'">Go To Google</button>
    </body>
    </html>
    Good Luck!

  • #5
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks so much!! I have add the [ code] next time.
    It is much different with my previous coding and it is work now. Thanks! =)

  • #6
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,073
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Thumbs up

    Quote Originally Posted by twinkle726 View Post
    Thanks so much!! I have add the [ code] next time.
    It is much different with my previous coding and it is work now. Thanks! =)
    You're most welcome.
    Happy to help.
    Good Luck!


  •  

    Tags for this Thread

    Posting Permissions

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