Multiple Check Boxes URL Jump TIA

T

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
 
L

Lasse Reichstein Nielsen

Tim said:
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
 
E

Egbert Beuker

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>
 
T

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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,223
Latest member
smithjens316

Latest Threads

Top