multiple list/menu

2

234

Please help.

I'm first start to use javascript but I don't know how to develop the
captioned.

e.g.
<select name="select" onChange="change(this.options.selectedIndex)">
<option value="0">---Please select---</option>
<option value="1">11111</option>
<option value="2">22222</option>
<option value="3">33333</option>
<option value="4">44444</option>
</select>

<select name="mySelect">
<option value="0">---Please select---</option>
</select>

Expected :
Select 11111, the "mySelect" show
<option value="1">123</option>
<option value="2">124</option>
<option value="3">125</option>
<option value="4">126</option>

Select 22222, the "mySelect" show
<option value="1">223</option>
<option value="2">224</option>
<option value="3">225</option>
<option value="4">226</option>

Select 33333, the "mySelect" show
<option value="1">345</option>
<option value="2">346</option>
<option value="3">347</option>

Select 44444, the "mySelect" show
<option value="1">444</option>
etc.
 
2

234

Found out other example but still not work.

<script>
var groups=document.forms[3].select.options.length <===== forms[3] ???
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()
group[0][0]=new Option("333","463") <==== "333" expected result ??
"463" ???
group[0][1]=new Option("444","464")
..
..
..
var temp=document.forms[3].mySelect <==== temp equal mySelect ???
function change(x)
{
x = x - 1

if (x == -1)
{
for (m=temp.options.length-1;m>=0;m--)
temp.options[m]=null
temp.options[0]=new Option("-------------","")
temp.options[0].selected=true
}
else
{
for (m=temp.options.length-1;m>=0;m--)
temp.options[m]=null
temp.options[0]=new Option("- Please select -","")
for (i=1;i<group[x].length+1;i++){
temp.options=new Option(group[x][i-1].text,group[x][i-1].value)
}
temp.options[0].selected=true <=== Completed this statement will
pass to mySelect select option ???

}
}

</script>




----- Original Message -----
From: "234" <[email protected]>
Newsgroups: comp.lang.javascript
Sent: Friday, March 05, 2004 12:04 AM
Subject: multiple list/menu
 

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,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top