Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2012, 02:27 AM   PM User | #1
twinkle726
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
twinkle726 is an unknown quantity at this point
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
twinkle726 is offline   Reply With Quote
Old 10-16-2012, 03:26 AM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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.
jmrker is offline   Reply With Quote
Users who have thanked jmrker for this post:
twinkle726 (10-16-2012)
Old 10-16-2012, 03:43 AM   PM User | #3
twinkle726
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
twinkle726 is an unknown quantity at this point
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>
twinkle726 is offline   Reply With Quote
Old 10-16-2012, 04:48 AM   PM User | #4
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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!
jmrker is offline   Reply With Quote
Old 10-16-2012, 07:23 AM   PM User | #5
twinkle726
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
twinkle726 is an unknown quantity at this point
Thanks so much!! I have add the [ code] next time.
It is much different with my previous coding and it is work now. Thanks! =)
twinkle726 is offline   Reply With Quote
Old 10-16-2012, 03:27 PM   PM User | #6
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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!
jmrker is offline   Reply With Quote
Reply

Bookmarks

Tags
alert, button, checkbox, submit

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39 PM.


Advertisement
Log in to turn off these ads.