I have a drop down box which has two values, when either is chose a seperate text box or another drop down box is opened. However it part works with the second option but not the first one. can someone have a look:

php/html code:

                <tr><td> 
                Choose Delivery Type </td>
               <td> <select name = 'elementtype1'id='elementtype1'           
                onchange='showfield(this.options[this.selectedIndex].value)'>
                        <option value='Select'>Select</option>
                        <option value='forwardorder'>Forward Order</option>
                        <option value='byreturn'>By Return</option>
                        </select></td>
                        <td>

                        <div id='div1'>Enter By Return Date<input type='text''name='whatever1' />
                        </div>


                        <div id='div2'>  
                        <td>Capacity</td>
                        <td><select name='deliveryDate'>"; 
                        $listCapacityDates = $cid->ListCapacity();
                        foreach($listCapacityDates as $x) {
                        $content .= "<option value='".$x['month']."'>".$x['month']."</option>";
                        }

                        $content .= "</div>
                        </td></tr>

Ajax Code:

                         function showfield(name){
                        if(name=='byreturn')document.getElementById('div1').style.display="block";
                         else document.getElementById('div1').style.display="none";

                          if(name=='forwardorder')document.getElementById('div2').style.display="block";
                          else document.getElementById('div2').style.display="none";

                           } 

Here is a Sample similar to what you are trying to achieve. Just view the source code of the page and it is pretty much self explanatory. I am experimenting with the jquery chained link plugin. Please do not hotlink the jquery files. That's all we are asking. please play by the rule..

the link you gave does not work. the server is blocking access to those directories.

thats so bizzzare. I'm connect via a proxy server i dont know whether that affects things.

it was because i was going through a proxy server. I got your script. thanks for that. i will try get my head around it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.