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
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.