multiple list/menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 234

    #1

    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="chang e(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.



  • 234

    #2
    Re: multiple list/menu

    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","4 63") <==== "333" expected result ??
    "463" ???
    group[0][1]=new Option("444","4 64")
    ..
    ..
    ..
    var temp=document.f orms[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" <234@234.com>
    Newsgroups: comp.lang.javas cript
    Sent: Friday, March 05, 2004 12:04 AM
    Subject: multiple list/menu

    [color=blue]
    > 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="chang e(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.
    >
    >
    >[/color]


    Comment

    Working...