PDA

View Full Version : dropdown box Question


mr_evans2u
05-05-2003, 10:42 PM
The following code works great for one dropdown, but if I add a second box and rename everything it doesn't work right. The first box will not go to the correct url's it goes to the url's of the second dropdown box.

What am I doing wrong??
Thank You



function UrlDropdown()
{
this.length = UrlDropdown.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = UrlDropdown.arguments[i]
}

var siteopt = new UrlDropdown("Select a relay",
"abc51",
"abc52",
"abc51",
"abc52",
"abc51",
"abc52",
"abc51",
"abc52");
var url = new UrlDropdown("",
"add_sieve.cgi?tflag=External1",
"add_sieve.cgi?tflag=External2",
"mod_sieve.cgi?tflag=External1",
"mod_sieve.cgi?tflag=External2",
"del_sieve.cgi?tflag=External1",
"del_sieve.cgi?tflag=External2",
"current.cgi?tflag=External1",
"current.cgi?tflag=External2");

function GoToURL(form)
{
i = form.SelectMenu.selectedIndex;
if (i == 0) return;
parent.frames[1].location.href = url[i+1];
}

/*###### Second box #######*/

function UrlDropdown1()
{
this.length = UrlDropdown1.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = UrlDropdown1.arguments[i]
}

var siteopt = new UrlDropdown1("Select a relay",
"abc51",
"abc52",
"abc51",
"abc52",
"abc51",
"abc52",
"abc51",
"abc52");
var url = new UrlDropdown1("",
"add_sieve.cgi?tflag=Internal1",
"add_sieve.cgi?tflag=Internal2",
"mod_sieve.cgi?tflag=Internal1",
"mod_sieve.cgi?tflag=Internal2",
"del_sieve.cgi?tflag=Internal1",
"del_sieve.cgi?tflag=Internal2",
"current.cgi?tflag=Internal1",
"current.cgi?tflag=Internal2");

function GoToURL1(form)
{
i = form.SelectMenu1.selectedIndex;
if (i == 0) return;
parent.frames[1].location.href = url[i+1];
}

HairyTeeth
05-05-2003, 11:04 PM
Just quickly, is it because you have two global variables called siteopt?

mr_evans2u
05-05-2003, 11:21 PM
Thanks HairyTeeth,
it wasn't siteopt but url. Once I changed the name of the variable url it worked fine.