Jump to content

Populating Dropdown


ShaolinF

Recommended Posts

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

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.