Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

click list box dynamic update

Status
Not open for further replies.

moviejunkie

IS-IT--Management
Oct 12, 2006
21
US
Hi, I have a page with a list box on it that is filled with names from an MYSql database using php.

I need to be able to click on a name and have it display all the information for that individual(name, address, ect...) automatacly in a set of labels with out loading another page

Help

Thanks
 
Help ... I just need somebooooooooody

Now seriously, what did you try so far?

Cheers,
Dian
 
I have no idea where to start, I have never worked with AJAX before
 
Have you researched AJAX at all? There are many, many simple examples out there (e.g. at Tizag.com). What do you know about it so far?

As a general guide, you will need to:
a) create a new PHP script that receives a GET or POST parameter (presumably an ID representing a person), runs a MySQL query to retrieve a person's details corresponding to the passed ID, and returns a fragment of HTML (for example) ready to plugin to the page.

b) on your existing page create an onclick event handler and associate it with the listbox. The handler should instantiate the XMLHttpRequest object and send the request to the new PHP script, passing the appropriate parameter. It should also receive the resultset returned by the new PHP script and process it (e.g. dynamically insert the fragment of HTML into the page).


Once you understand the finer detail of how AJAX works, it might be worth using a higher-level implementation like jQuery. SitePoint have published a nice article entitled Easy Ajax with jQuery.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
You can build the structure you need with this site.

it can handle the connected tables (Country)

Then you get a member updater code, where the connected table appears in a select box with the related value as selected.

That generator page has a video tutorial.

And example how the code looks like:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top