hi all, i want to create two level drop down list , and the data are retrive from mysql , the first and the second drop down list data are all from the same table of my db, for example : data are a, b,c,d 1.when user select 'a' from select_1 then select_ 2 only shown b,c,d 2.when user select 'b' from select_1 then select_ 2 only shown a,c,d 3...... anyone knows how to do ?
first write the html markup for them, and add onchange in 1st drop down like this <select onchange="javascript:FunctionToCallServerBack(withSelectedItem) .......... then do the DB process and re-render the second dropdown
it's my code , but still can't show drop down list for select_2 , what's wrong with my code ? <script> function buildSelect2($select1) { <? echo "<td>"; $sql = "select addr from customer where addr <>$select1"; echo "<select name=\"select2\" size=\"0\" >" ; for ($i=0;$i<$result_num;$i++) { $row = mysql_fetch_array($result); $addr= $row['addr']; echo "<option value=$addr>$addr</option>"; } echo "</td>"; ?> } </script> .................. echo "<td>"; echo "<select name=\"select1\" size=\"0\" onchange = buildSelect2(this) >" ; for ($i=0;$i<$result_num;$i++) { $row = mysql_fetch_array($result); $addr= $row['addr']; echo "<option value=$addr>$addr</option>"; } echo "</td>";