|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Drop Down Click Event
hi
I want to populate a second dropdown with data from the database, based on the value or text selected inthe first dropdown. The first and second dropdown are going to be in the same page, with the first dropdown being loaded with certain data from database and the second dropdown will get populated only after clicking a value or text from the first drop down. I have tried to write a code for this, but unfortunately its not working. Can anybody help me in resolving this problem. My Code: <html> <body> <form method="post" action="CustomerInformation2.php"> <?php include ("DbConnection1.php")?> <? echo "<select id=\"DropName\" name=\"DropName\" onclick=\"CircuitInfo()\" method=\"post\">"; $sql = "select distinct CustomerID,CustName from Customer"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $varID=$row["CustomerID"]; $varName=$row["CustName"]; echo "<OPTION for=\"DropName\">".$varName.'</option>'; echo "<br>"; } mysql_free_result($result); /* This Function i have written to populate the second dropdown with data from the database based on the text or value selected in the first dropdown*/ function CircuitInfo() { global $varID; echo "<select id=\"DropCircuit\" name=\"DropCircuit\">"; $sql1="select CircuitID from Contract where CustomerID='".$varID."' "; $res=mysql_query($sql1); $opt=""; while ($row1=mysql_fetch_array($res)) { $varcirID=$row1["CircuitID"]; echo "<OPTION for=\"DropCircuit\">".$varcirID.'</option>'; echo "<br>"; } mysql_query($res); } ?> <input name="step" type="hidden" value="1" /> <input name="submit" type="submit" value="add"/> </select> </form> </body> </html> Hoping for some positive results. Thanking you ri |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Drop Down Click Event |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|