javascript help...

Discussion in 'JavaScript' started by only21raj2003, Sep 8, 2005.

  1. #1
    Hi..

    I have 2 combo boxes,they are interrelated.for every selection of the first combo box it displays corresponding items in the second combo box.

    Now here is the problem.

    For the last selection in the fiirst combo box it should display a text box for text input but not the combo box(the current code displays the combo box).

    Also for a particular selection in the first combo box there is an item "others" in the second combo. if i select others it should pop up a text box.


    Here is the code.
    <form name="doublecombo">

    <tr>
    <td class="bodyText" colspan="2">&nbsp;</td>
    </tr>

    <TR>
    <TH class=bodyText align=left width="290" height="29">&nbsp;<b>&nbsp;BCP Type:&nbsp;</b><SELECT onchange=redirect(this.options.selectedIndex)
    size=1 name=example size="1"> <OPTION>Computer Hardware</OPTION>
    <OPTION>Computer Software</OPTION>
    <OPTION>Data Storage</OPTION>
    <OPTION>Non-Computer Equiptment</OPTION></SELECT></TH></TR>
    <P></P>




    <tr>
    <td class="bodyText" colspan="2">&nbsp;</td>
    </tr>

    <tr>
    <td class=bodyText align=left width="290" height="32">&nbsp; <b>&nbsp;BCP
    Item:</b>

    <select name="stage2" size="1">
    <option value="">PC Desktop</option>
    <option value="">PC Workstation</option>
    <option value="">UNIX Workstation</option>
    <option value="">LINUX Workstation</option>
    </select>
    </td>
    </tr>
    </p>





    <script>

    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group=new Array()

    group[0][0]=new Option("PC Desktop")
    group[0][1]=new Option("PC Workstation")
    group[0][2]=new Option("UNIX Workstation")
    group[0][3]=new Option("LINUX Workstation")

    group[1][0]=new Option("MS-Visual Studio")
    group[1][1]=new Option("GCC-GNU Compiler")
    group[1][2]=new Option("Sun C Compiler")
    group[1][3]=new Option("Mentor Graphics Tools")
    group[1][4]=new Option("Cadence Tools")
    group[1][5]=new Option("Matlab")
    group[1][6]=new Option("Other")

    group[2][0]=new Option("Milkyway Servers")
    group[2][1]=new Option("ITD Servers")
    group[2][2]=new Option("Lost Servers")
    group[2][3]=new Option("Share(s) on Servers")
    group[2][4]=new Option("Local Storage")

    group[3][0]=new Option("Non-Computer equiptment")



    var temp=document.doublecombo.stage2

    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options=new Option(group[x].text,group[x].value)
    }
    temp.options[0].selected=true
    }

    function go(){
    location=temp.options[temp.selectedIndex].value
    }
    //-->
    </script>



    Please help me..

    Thank you,
    RAJ
     
    only21raj2003, Sep 8, 2005 IP