ShaolinF Posted February 2, 2008 Share Posted February 2, 2008 Hi Guys, I have a drop down menu which onload want to populate, and once populated, when the user selects an option it will update several text fields. This is what I have done so far: HTML: <select id="menu" name="menu"> <option value="">-Select-</option> </select> JAVASCRIPT: function GetDropList () { //Create request var xhr = CreateRequest(); //Add query xhr.open("GET","requestList.php?action=getlist",true); xhr.onreadystatechange=function() { if(xhr.readyState==4) { var createNewElement = document.createElement('option'); } } xhr.send(null); } window.onload = function() { GetDroplist(); } PHP: <?php include("../../db_connect.php"); switch ($_GET['action']) { case getlist: $result = mysql_query('SELECT * FROM event') or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo $row['eventName']; break; } } ?> As you can see I am currently trying to workout how I am going to populate the list. Once that is done then I intend to update specific textfields on user selection. I have no idea how to do that (on the js side) because my php script will output several variables. Link to comment https://forums.phpfreaks.com/topic/89024-populating-dropdown/ Share on other sites More sharing options...
phpQuestioner Posted February 11, 2008 Share Posted February 11, 2008 Google "AJAX Chain Select Menus" - Should Be Plenty of Examples/Tutorials & Live Demos; Showing You How To Do This. Link to comment https://forums.phpfreaks.com/topic/89024-populating-dropdown/#findComment-464295 Share on other sites More sharing options...
priti Posted February 12, 2008 Share Posted February 12, 2008 you can search the same topic in this forum also i have answered this before here Link to comment https://forums.phpfreaks.com/topic/89024-populating-dropdown/#findComment-464794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.