...

View Full Version : Fighting the arrays



lash
04-10-2003, 09:13 PM
Hi there
I’ve got two <select>-boxes. The second box changes options according to the first <select>. This works fine, but how do I attach values, in this case URL’s, to the second <select>? Normally this wouldn’t be a problem, but since this script works with arrays it confuses me.
I found the script on the internet.

Check out 'my' script (http://www.larsliin.dk/test.htm)

ez4ne12c
04-10-2003, 09:46 PM
Its not really clear what you are asking for....
maybe try something like this..

<SCRIPT LANGUAGE="JavaScript">
<!--//
function addOption(){
temp =new Array()
for (a=0; a<document.f.s.options.length; a++){
temp[a] = document.f.s.options[a].text
}
temp[temp.length]= document.f.t.value
for (b=0; b<temp.length; b++){
document.f.s.options[b]=new Option(temp[b])
}
document.f.s.selectedIndex=0
}
//-->
</SCRIPT>
<FORM NAME=f>
<INPUT TYPE=text name=t>
<INPUT TYPE=button onclick=addOption() value="add option >>">
<SELECT NAME=s>
<OPTION>Hello
<OPTION>HI
<OPTION>Bye
</SELECT>

</FORM>
ez
:) hope its helpful :)

lash
04-10-2003, 10:00 PM
Thanks, but not exactly what I was looking for - or perhaps I'm missing out on something here?
Check out my form: http://larsliin.dk/test.htm

When I choose one of the options in the right box, I need to go to an URL. I need to attach values to the options. This is difficult since the right box works with arrays. How can this be solved?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum