By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,120 Members | 1,786 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,120 IT Pros & Developers. It's quick & easy.

Multiple Check Boxes URL Jump TIA

P: n/a
Tim
Hello All!

I'm having a difficult problem and I'm wondering if anyone can help.
Here's the deal.

I have a webpage with multiple forms on it. All of the forms have drop
down boxes that when selected and the corresponding button is pressed, the
user should be taken to a new website.

However, since I have 41 forms and 41 corresponding checkboxes, I would
like one function that can manage the 41 different forms.

Here's what I've tried so far, but it doesn't work. drop_num would be
the number of the form involved. In this case, all 41 forms are named as
follows: the first form is named Form1, the second Form2 and so forth all
the way till Form41. The drop down boxes are named as follows: the first
WebPage1, second WebPage2, etc.

The buttons activate the ChangeURL function with the OnClick() function.

function ChangeURL(drop_num)
{
if (navigator.appName.indexOf('Netscape') > -1) {
location.href = drop_num + "." + "WebPage" + drop_num + "." + "options["
+ drop_num + "." + "WebPage" + drop_num + "." + "selectedIndex].value";
}
else {
location.href = drop_num + "." + "WebPage" + drop_num + "." + "value";
}
}

Thanks in advance,

Tim

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Tim" <mr********@yahoo.com> writes:
function ChangeURL(drop_num)
{
if (navigator.appName.indexOf('Netscape') > -1) {
That matches both Netscape 4 and Netscape 7, where Netscape 7 does have
the value directly on the select element.
location.href = drop_num + "." + "WebPage" + drop_num + "." + "options["
+ drop_num + "." + "WebPage" + drop_num + "." + "selectedIndex].value";


I assume the value of the option is the URL of the new page. Here, you
just create a string that ends in ".value", not the URL that it refers
to.

Try:

var sel = document.forms['Form'+drop_num].elements['WebPage'+drop_num];
location.href = sel.options[sel.selectedIndex].value;

If you want to support Netscape 4, you might as well *just* use the
above. It still works on all the newer browsers that also have the
value on the select element.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Why don't you put the form object into the function?
You can name all the listboxes the same then!

function changeURL(frm)
{
window.navigate(frm.webpagedropdown.value)
}

<form id="form1">
<select id="webpagedropdown">
[options go here]
</select>
<button onclick="changeURL(this.form)">
</form>

<form id="form2">
<select id="webpagedropdown">
[options go here]
</select>
<button onclick="changeURL(this.form)">
</form>

"Tim" <mr********@yahoo.com> wrote in message
news:jy*********************@twister.socal.rr.com. ..
Hello All!

I'm having a difficult problem and I'm wondering if anyone can help.
Here's the deal.

I have a webpage with multiple forms on it. All of the forms have drop
down boxes that when selected and the corresponding button is pressed, the
user should be taken to a new website.

However, since I have 41 forms and 41 corresponding checkboxes, I would like one function that can manage the 41 different forms.

Here's what I've tried so far, but it doesn't work. drop_num would be
the number of the form involved. In this case, all 41 forms are named as
follows: the first form is named Form1, the second Form2 and so forth all
the way till Form41. The drop down boxes are named as follows: the first
WebPage1, second WebPage2, etc.

The buttons activate the ChangeURL function with the OnClick() function.
function ChangeURL(drop_num)
{
if (navigator.appName.indexOf('Netscape') > -1) {
location.href = drop_num + "." + "WebPage" + drop_num + "." + "options[" + drop_num + "." + "WebPage" + drop_num + "." + "selectedIndex].value";
}
else {
location.href = drop_num + "." + "WebPage" + drop_num + "." + "value";
}
}

Thanks in advance,

Tim

Jul 20 '05 #3

P: n/a
Tim
Egbert,

Thank you! It works perfectly!

Tim
Why don't you put the form object into the function?
You can name all the listboxes the same then!

function changeURL(frm)
{
window.navigate(frm.webpagedropdown.value)
}

<form id="form1">
<select id="webpagedropdown">
[options go here]
</select>
<button onclick="changeURL(this.form)">
</form>

<form id="form2">
<select id="webpagedropdown">
[options go here]
</select>
<button onclick="changeURL(this.form)">
</form>

"Tim" <mr********@yahoo.com> wrote in message
news:jy*********************@twister.socal.rr.com. ..
Hello All!

I'm having a difficult problem and I'm wondering if anyone can help.
Here's the deal.

I have a webpage with multiple forms on it. All of the forms have drop down boxes that when selected and the corresponding button is pressed, the user should be taken to a new website.

However, since I have 41 forms and 41 corresponding checkboxes, I

would
like one function that can manage the 41 different forms.

Here's what I've tried so far, but it doesn't work. drop_num would be the number of the form involved. In this case, all 41 forms are named as
follows: the first form is named Form1, the second Form2 and so forth all the way till Form41. The drop down boxes are named as follows: the first
WebPage1, second WebPage2, etc.

The buttons activate the ChangeURL function with the OnClick()

function.

function ChangeURL(drop_num)
{
if (navigator.appName.indexOf('Netscape') > -1) {
location.href = drop_num + "." + "WebPage" + drop_num + "." +

"options["
+ drop_num + "." + "WebPage" + drop_num + "." + "selectedIndex].value";
}
else {
location.href = drop_num + "." + "WebPage" + drop_num + "." + "value"; }
}

Thanks in advance,

Tim


Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.