Jump to content

Populating Dropdown box from MySQL


jester626

Recommended Posts

I am hacking a lookup script that when I enter in the club member ID number it places the member's info into a field. The script works just fine when populating simple text fields, however I have one field called status that I want to use a drop down menu. basically I want the dropdown to display the members current membership status but be able to select other status levels if we need to.

 

The form element on lookup.php looks like this

Membership Status:               

                  <select name="membershipstatus" id="membershipstatus">

                  </select>

 

and the query page getmember.php) looks like this

 

echo "formObj.membershipstatus.value = '".$inf["membershipstatus"]."';\n";

 

any help on how to tie these two together would be greatly appreciated.

 

Jester

Link to comment
Share on other sites

I am not sure if this will help you but i achieved population of my drop downs via the following:

 

On my form page the select was displayed as normal the key being the onchange event for me -  when the on change executes it jumps to the function that tells it to run the php page which returns the result -- in my useage i had three drop downs one based upon another - the initial just loading values from a mysql table.

 

<select name="example" id="example"  onchange="getexample(this)">
                <option value="">Select</option>
              </select>

 

 

this is the getexample() function (well a stripped back version)

 

function getday(sel)
{
var cday = sel.options[sel.selectedIndex].value;
ajax.requestFile = 'getdays.php?cday='+cday;
ajax.onCompletion = createday;	
ajax.runAJAX();
}}

 

 

the creatday function below:

 

function createday()
{
var obj = document.getElementById(day');
eval(ajax.response);
}

 

 

Hope that helps i haven't tested this stripped back version but it might give you a little help...

Link to comment
Share on other sites

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.