Results 1 to 3 of 3
Nov 30, 2011, 23:02 #1
- Join Date
- Nov 2011
- 0 Post(s)
- 0 Thread(s)
Reload Dropdown list without refresing page
How can I execute this:
From the dropdown list build up from mysql database (say a list of fruits).
I select "Add New Fruit". This triggers it to either have a modal form to add new fruit or a table form.
Once submitted, Select dropdown list RELOADS including the newly added data (fruit) without reloading the whole page which contains other form control such as textbox.
Dec 1, 2011, 04:34 #2
Dec 1, 2011, 10:48 #3
On the Client
As infoxicated said, jQuery is way, way simpler than trying to do this yourself. In particular, it has a load function that makes an AJAX request, assumes that the returned data is HTML, and inserts the HTML into whatever element you choose:
$(yourSelect).load('somepage.php'); // so easy!
On the Server
The only argument you'll (probably) need to pass to the load function is the URL of a page that will spit out an HTML fragment. I used PHP in that example, but only because that's the only language I know. It can be any type you want.
Whatever language you choose, it needs to do the following:
I'm the web overlord for Graphic Business Systems
- Get the current list from the database.
- Turn that list into an HTML string.
- Echo or print the string.