 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
PiperJim
Joined: 01 Dec 2007 Posts: 6
|
Posted: Sat Dec 01, 2007 1:34 am Combination of 4 Check Boxes |
|
|
|
I wish to set up a page with 4 check boxes so that you can select a combination of all 4 boxes A, B, C, D.
(ie) By selecting A you will go to a page title A
By selecting A,C you will go to a page title AC and so on
is this possible with javascript as I have been looking for a program for a few days now with no success
Thanks PiperJim |
|
camoman666

Joined: 24 Jun 2006 Posts: 373 Location: Fort Walton Beach, FL, USA
|
Posted: Sun Dec 02, 2007 10:33 am |
|
|
|
Chose one of either the Brute Force JavaScript or the Simple JavaScript function and paste it into your HEAD section.
JavaScript (Brute Force):
| Code: |
<script type="text/JavaScript">
<!--
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var page;
function route(){
if(document.boxes.a.checked==true){
a = 1;
}
if(document.boxes.b.checked==true){
b = 1;
}
if(document.boxes.c.checked==true){
c = 1;
}
if(document.boxes.d.checked==true){
d = 1;
}
if(a){
if(b){
if(c){
if(d){
page = "abcd.html";
}else{
page = "abc.html";
}
}else{
if(d){
page = "abd.html";
}else{
page = "ab.html";
}
}else{
if(c){
if(d){
page = "acd.html";
}else{
page = "ac.html";
}
}else{
if(d){
page = "ad.html";
}else{
page = "a.html";
}
}
}
}else{
if(b){
if(c){
if(d){
page = "bcd.html";
}else{
page = "bc.html";
}
}else{
if(d){
page = "bd.html";
}else{
page = "b.html";
}
}
}else{
if(c){
if(d){
page = "cd.html";
}else{
page = "c.html";
}
}else{
if(d){
page = "d.html";
}else{
page = "none.html";
}
}
}
}
window.location = page;
}
-->
</script> |
JavaScript (Simple):
| Code: |
<script type="text/JavaScript">
<!--
var page = "";
function route(){
if(document.boxes.a.checked==true){
page = "a";
}
if(document.boxes.b.checked==true){
page = page + "b";
}
if(document.boxes.c.checked==true){
page = page + "c";
}
if(document.boxes.d.checked==true){
page = page + "d";
}
if(page==""){
page = "none.html";
}else{
page = page + ".html";
}
window.location = page;
}
-->
</script> |
Form:
| Code: |
<form name="boxes" action="javascript:route()">
<input type="checkbox" name="a">
<input type="checkbox" name="b">
<input type="checkbox" name="c">
<input type="checkbox" name="d">
<input type=submit value="Submit">
</form> |
Either JavaScript method will work, but the seccond one will take up less memory on your server. |
|
PiperJim
Joined: 01 Dec 2007 Posts: 6
|
Posted: Sun Dec 02, 2007 12:18 pm Thanks |
|
|
|
Thank you camoman666
Thats great and perfect
Many, many, many, thanks |
|
camoman666

Joined: 24 Jun 2006 Posts: 373 Location: Fort Walton Beach, FL, USA
|
Posted: Sun Dec 02, 2007 12:36 pm |
|
|
|
| It's no problem, I'm always glad to help. |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|