I am trying to populate a drop down list in an HTML form that pulls it's data from a datbase. Basically, the users can manage the values via a differnt interface, but the web page will present what ever values are in a given list. I can make the list from the database as a set of value pairs, but I can't figure out how to take that list and "import it" into an HTML page. I didn't post any code since nothing comes close to working.

If I have this list:

Item, Name
A001, Cats
A002, Dogs
A003, Birds

what do I do to pull this into a form?

Thanks in advance.

What language are you using the for backend? (PHP, ASP, whatever)

The application is written in XBase++ using Advantage Database server. We are developing a web front-end for the normal application. (I know not many use the language but we came over from an old Clipper application.) All the data is encrypted for medical reasons. The end users can maintain the data lists in the normal PC/Serve based applcation. we want to be able to use these same lists in the web front-end but not allow any editing. So I can get the list out, decrypted and ready to use. I just don't know how to take that list and turn it into the HTML select list. Clear as mud??

please write your select list and populate it manually as an example so we can have some idea on what you seek, in fact to have something we can refer (to and from) in our possible explanations that might turn up.

Are you sure you want them in a drop-down list?

This is a sample of a list I would use. The option value is the value that will be stored with the post. I can't hard code the list because each client can have more, less, and other defined terms. The users maintain the lists in a fully relational database.

<select name="disposition">
<option value="A001" SELECTED>Scene</option>
<option value="A002">Interfacility</option>
<option value="A003">PR - Scene</option>
<option value="A004">PR - Interfacility</option>
<option value="A005">Search</option>
<option value="A006">Transport Team</option>
<option value="A007">Maintenance</option>
<option value="A008">Administrative</option>
<option value="A009">Pilot Recurrency</option>
<option value="A010">Crew Training</option>
</select>

I am 99% sure I want a drop-down list - unless there is a better way to allow the end user to select from a list. I thought a drop-down would be the best because I can export/create a list of data from the databases, I just don't know how to take the raw text list and drop it into the HTML code.

The regular application is used for flight dispatch and patient charting for Air Medical helicopters. Our clients want a web front end to do some tasks like scheduling flight requests. With over 130 clients, they each have different ideas of what should be in any given list. The example above is from a list of possible request types.

THanks again in advance for your help.

commented: yes and it is your duty to mark the thread as solved or at least say thanks when somebody solves your problem, especially problems you get payed to solve yourself +0

This is a sample of a list I would use. The option value is the value that will be stored with the post. I can't hard code the list because each client can have more, less, and other defined terms. The users maintain the lists in a fully relational database.

<select name="disposition">
<option value="A001" SELECTED>Scene</option>
<option value="A002">Interfacility</option>
<option value="A003">PR - Scene</option>
<option value="A004">PR - Interfacility</option>
<option value="A005">Search</option>
<option value="A006">Transport Team</option>
<option value="A007">Maintenance</option>
<option value="A008">Administrative</option>
<option value="A009">Pilot Recurrency</option>
<option value="A010">Crew Training</option>
</select>

I am 99% sure I want a drop-down list - unless there is a better way to allow the end user to select from a list. I thought a drop-down would be the best because I can export/create a list of data from the databases, I just don't know how to take the raw text list and drop it into the HTML code.

The regular application is used for flight dispatch and patient charting for Air Medical helicopters. Our clients want a web front end to do some tasks like scheduling flight requests. With over 130 clients, they each have different ideas of what should be in any given list. The example above is from a list of possible request types.

THanks again in advance for your help.

good.
this would be your HTML

<form name="dropDown" action="" method="" >
<select name="disposition">
<option value="" >Select Scene</option>
</select>
</form>

this would be the string format retrieved from your dB:

var	list = "A001, Scene, A002, Interfacility, A003, PR - Scene, A004, PR - Interfacility, A005, Search, A006, Transport Team, A007, Maintenance, A008, Administrative, A009,Pilot Recurrency, A010,Crew Training" 
	list = list.split(',')//this is where we split it to make it usable.

this would be your function:

function addDropList(list, target){
	for(var i=0; i<list.length; ++i){
			var	o = document.createElement("option"), a=""+ i/2;
		if( a.indexOf(".") == -1 ){
			o.value = list[i];
			o.text = list[i+1];
			target.options.add(o);
		}
		
	}
}

and this your execution method:
addDropList(list, document.dropDown.disposition)

Sorry I have not responded - sometimes my real job takes me away from my programming job!! This works perfectly. I am going to try and add additional drop-downs to the same page by editing the code. Wish me luck. I will be back if I can't figure it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.