I have a Dynamic drop down that is populated from MySQL table query. I need to setup an event listner on that drop down and use the selected 4 digit number and apply that to a query to populate a total of 6 Text fields. Does anyone have any ideas?
Okay, this is the code I have. The Top 3 boxes work fine. I get the Department, position and I recieve the Cube numbers like I need, however, I need to get the additional info populated from the selection of the cube. How would I do this? Please help... [CODE<html> <head> <script language='javascript'> var position = new Array(); position['TS'] = ",TSR,Seasonal TSR,TS Lead"; position['CS'] = ",CSR,Seasonal CSR,CS Lead"; position['TC'] = ",TelCo,TC Lead"; var cube = new Array(); cube['TSR'] = "<?php $conn = mysql_connect('Server','UID','PWD'); $db = mysql_select_db('DB Name'); $sql = ("SELECT Cube FROM `employees` WHERE Position='TSR' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; $out = ""; ?>"; cube['Seasonal TSR'] = "<?php $conn = mysql_connect(Connection info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='S-TSR' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; $out = ""; ?>"; cube['TS Lead'] = "<?php $conn = mysql_connect(Connection info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='TS-Lead' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; $out = ""; ?>"; cube['CSR'] = "<?php $conn = mysql_connect(Connection Info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='CSR' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; ?>"; cube['Seasonal CSR'] = "<?php $conn = mysql_connect(Connection Info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='S-CSR' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; ?>"; cube['CS Lead'] = "<?php $conn = mysql_connect(Connection Info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='CS-Lead' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; ?>"; cube['TelCo'] = "<?php $conn = mysql_connect(Connection info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='Tel-Co' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; ?>"; cube['TC Lead'] = "<?php $conn = mysql_connect(Connection info); $db = mysql_select_db('techmap'); $sql = ("SELECT Cube FROM `employees` WHERE Position='TC-Lead' ORDER BY `employees`.`Cube` ASC"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $out .= ",$row[Cube]";//Drop down options } echo $out; ?>"; function loadOptions(sParentBox, sChildBox) { //get the value of the selected option var sParentValue = document.getElementById(sParentBox).value; //load the appropriate event list to the option box var theSel = document.getElementById(sChildBox); //clear previous options theSel.options.length = null; //handle if there is no value if (sParentValue == ''){return;} if (sParentBox == "department") { oTargetArray = position; }else if(sParentBox == "position"){ oTargetArray = cube; } //split the array values by the separator var arrList = oTargetArray[sParentValue].split(","); //loop thru the array of options to add them to the dropdown for (TS=0; TS < arrList.length; TS++) { var newOpt = new Option(arrList[TS], arrList[TS]);//(theText,theValue); var selLength = theSel.length; theSel.options[selLength] = newOpt; }//next }//end func </script> </head> <body> <form action="update.php" method="post"> <table> <tr> <td>Select the Department: </td> <td> <select name="department" id="department" onchange="loadOptions(this.name,'position');"> <option value=''></option> <option value='TS'>Technical Support</option> <option value='CS'>Customer Service</option> <option value='TC'>Tel-Co</option> </select> </td> </tr> <tr> <td>Select the Position: </td> <td> <select name="position" id="position" onchange="loadOptions(this.name,'cube');"> </select> </td> </tr> <tr> <td>Select the Cube Number: </td> <td> <select name="cube" id="cube"></select> </td> </tr> <tr><td>First Name: </td><td><input type="text" name="RepFirst"></td></tr> <tr><td>Last Name: </td><td><input type="text" name="RepLast"></td></tr> <tr><td>Phone: </td><td><input type="text" name="Phone"></td></tr> <tr><td>Lunch Time: </td><td><input type="text" name="Lunch"></td></tr> <tr><td>Instrument Number: </td><td><input type="text" name="InstNum"></td></tr> <tr><td>E-Mail Address: </td><td><input type="text" name="EMail"></td></tr> <tr><td><input type="Submit"></tr></td> </form> </table> </body> </html>[/CODE]