Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

populating a select from an sql table created by a prior select

Posted on 2014-08-11
3
Medium Priority
?
178 Views
Last Modified: 2014-08-12
I have 2 selects in my form

The first one creates a table with the selections the client makes.

This table is cleared at the beginning.

The second select is based on 2 tables, a main table and the table crated in the first selection.

When I open the site all selections are clear, when I finish the first selection the second one is still clear, I need to populate without reloading the page since it resets all the tables. (mainly the first with the selected values)

Is there a way to have it populated when I hover or click on the 2nd select?
0
Comment
Question by:robrodp
3 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 2000 total points
ID: 40255332
you need to use an ajax call to create the options list and then use this to populate the second select

use jQuery for the ajax call, it will save you some time and effort
http://api.jquery.com/jquery.ajax/

use a call back function to populate the select with the new options
at it's most basic it will be something like this
$j.ajax({
			type: "GET",
			url: "random-post.php?lang=" + $j.ifen('en','fr'),
			dataType: "html",
			success: function(msg){
						//do something;		                
				}
		});	

Open in new window


some caveats

some versions of IE do not like having the option list updated so you will need to replace the entire select
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 40255463
The first one creates a table with the selections the client makes.
Can you be more specific? It sounds as if this part is working except it's not populating the second select. Is that correct? If so, are you using ajax to create this table or are you submitting and reloading the page when the first selection is made?
0
 

Author Closing Comment

by:robrodp
ID: 40256166
Thx.. the IE comment makes it a no no.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question