PDA

View Full Version : Checkboxes do redirect


Apolinho
06-25-2002, 04:42 PM
I need a script that redirects me to a page depending on which checkboxes have been checked. For example, I have a pege with 4 checkboxes: 1,2,3,4. If the user checks '1', he will be redirected to '1.html'. If the users checks '1' and '2' checkboxes, he will be redirectetd to '12.html'. If the user checks all checkboxes, he will be redirected to '1234.html' and so. Thanks in advance.

Apolinho

richard_r
06-25-2002, 04:53 PM
What are the possibilities of page names..

ckbx1+ckbx3 = 13.html
ckbx1+ckbx2 = 12.html

what are the possiblities of the check boxes?

1.html
2.html
3.html
4.html
1234.html

that is it right?

Apolinho
06-25-2002, 07:46 PM
Richard, the possibilities are:

chkbox1 alone= 1.html
chkbox2 alone= 2.html
chkbox3 alone = 3.html
chkbox4 alone = 4.html
chkbox1 + chkbox2 = 12.html
chkbox1 + chkbox3 = 13.html
chkbox1 + chkbox4 = 14.html
chkbox2 + chkbox3 = 23.html
chkbox2 + chkbox4 = 24.html
chkbox3 + chkbox4 = 34.html

Okay?

Apolinho
06-25-2002, 07:50 PM
Soyy, I've made a mistake
Richard, the possibilities are:

chkbox1 alone= 1.html
chkbox2 alone= 2.html
chkbox3 alone = 3.html
chkbox4 alone = 4.html
chkbox1 + chkbox2 = 12.html
chkbox1 + chkbox3 = 13.html
chkbox1 + chkbox4 = 14.html
chkbox2 + chkbox3 = 23.html
chkbox2 + chkbox4 = 24.html
chkbox3 + chkbox4 = 34.html
chkbox1+ chkbox2+ chkbox3 = 123.html
chkbox1+ chkbox2+ chkbox4 = 124.html
chkbox1+ chkbox3+ chkbox4 = 134.html
chkbox1+ chkbox2+ chkbox3 = 123.html
chkbox2+ chkbox3+ chkbox4 = 123.html
chkbox1+ chkbox2+ chkbox3 + chkbox4 = 1234.html

Boring, isn't it?

richard_r
06-26-2002, 03:24 AM
Now that I understand this a little bit better..

I am thinking that you will have to call for a function that checks to see which chkbxs have been selected.. and then by which are selected would determin the site..

<script language="JavaScript">
function openPage() {
// the function properties in here
onClick=window.// other properties
}
<input type=checkbox name="// possible number(s)>
<body onLoad="openPage()">

That is a real sketchy dipiction of what the codeing would look like. Maybe you should wait until another member with more knowledge to help.. I am not too sure if that will work.

Hope that I helped.

glenngv
06-26-2002, 04:24 AM
script:

function openPage(){
var frm = document.yourformname;
var page="";
for (var i=1;i<=4;i++){
objChk = eval("frm.chkbox"+i);
if (objChk.checked) page+=""+objChk.value;
}
page+=".html";
location.href=page;
}


html:

<input type="checkbox" name="chkbox1" value="1">Checkbox 1
<input type="checkbox" name="chkbox2" value="2">Checkbox 2
<input type="checkbox" name="chkbox3" value="3">Checkbox 3
<input type="checkbox" name="chkbox4" value="4">Checkbox 4

<input type="button" value="Open" onclick="openPage()">

richard_r
06-26-2002, 10:22 PM
I was missing about half of the form properties, but I had the right idea in mind.... I will have to change my quote..