Shaolins-Finest
02-02-2008, 12:26 AM
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]
<?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;
}
}
?>
[PHP]
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.
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]
<?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;
}
}
?>
[PHP]
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.