underlink Posted August 5, 2013 Share Posted August 5, 2013 Not sure how to go about this task but I imagine it requires some sort of foreach loop I have a drop down list populated by a label called LST_Type, this table only exists to provide options for this dropdown list The value selected on the dropdown menu gets written to a table called "assets". when the users clicks away from the form (using ajax) Here is what I need to happen: On page load the dropdown list need its default option to be whatever the current value of the record is in the "asset" table. As the only way you can insert data into this field is via the dropdown list it will always be somethig from the "LST_Type" table The reason is that the data is written to the fields when you click away from the input boxes and unless you are editing the "Type" record it updates it to its default selection. hope this makes sense here is my code: <tr id="<?php echo $id; ?>" class="edit_tr"><!-- Title Colum --><td class="style4" style="font-size:14px;width:200; height:35px; class="edit_td"> Type: </td><td style="font-size:14px;width:270px;border:solid 0px #000;padding:0px; class="edit_td"><span style="color:#0066CC;" id="type1_<?php echo $id; ?>" class="text"><?php echo $Type; ?></span><!-- ***************************************START - This Is the dropdown menu script *********************************************** --> <script type="text/javascript"> function OnDropDownChange2(dropDown) { var selectedValue = dropDown.options[dropDown.selectedIndex].value; document.getElementById("type1_input_<?php echo $id; ?>").value = selectedValue; } </script><select name = "MYtype" id="type1_input_<?php echo $id; ?>" class="editbox" onChange="OnDropDownChange2(this);">><?php$sql = mysql_query("SELECT Type FROM LST_Type");while ($row = mysql_fetch_array($sql)){echo "<option value='" . $row['Type'] . "'>" . $row['Type'] . "</option>";}?></select><input type="text" value="<?php echo $Type; ?>" class="editbox" id="type1_input_<?php echo $id; ?>" /> /><!-- ***************************************END *********************************************** --> Quote Link to comment Share on other sites More sharing options...
underlink Posted August 5, 2013 Author Share Posted August 5, 2013 Sorry about duplicating title from old post. Stupid Chromes fault Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.