469,903 Members | 1,667 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

multiple list/menu

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.

Jul 20 '05 #1
1 1340
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[i]=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[i]=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" <23*@234.com>
Newsgroups: comp.lang.javascript
Sent: Friday, March 05, 2004 12:04 AM
Subject: multiple list/menu

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.

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.