PDA

View Full Version : PHP Lists and Fields problem



denizengt
March 14th, 2006, 01:43 AM
I have a page called "Edit_Entry.php". Within this I have a drop down list of names from a simple addressbook table in my database. This table contains simply, a name and a number.

I have two text fields in the page below the drop down list named "name" and "number".

What I'm trying to do, is when you select a name from the list, the two text fields automatically display the name and number associated with this. I have an edit button, so the user can edit these text fields contents and then submit it back into the database, therefore updating the entry.

My issue is, I don't know how to automatically update those two text feilds with the details associated with the selected name in the drop down list.

Can anyone give me some assistance?

Jeff Wheeler
March 14th, 2006, 01:45 AM
You'll want to do an ajax request to PHP communicating with your database. Here's a great tutorial that does something very similar:
http://www.webpasties.com/xmlHttpRequest/

denizengt
March 14th, 2006, 01:55 AM
Is that crossbrowser compatible?

It also seems a bit much to simply update two text fields on a dropdown choice.

Jeff Wheeler
March 14th, 2006, 03:11 AM
Yes for #1, and no for #2. Everybody uses it… it's the latest big thing. ;)

denizengt
March 14th, 2006, 05:56 AM
*suspicious* Everyone does it eh? DO I LOOK LIKE A SHEEP TO YOU?!! :D

Alright, I'll give it a whirl :)

Jeff Wheeler
March 14th, 2006, 04:56 PM
It's called Ajax, and it's the foundation for just about every "web 2.0" app you'll find.

http://www.google.com/search?q=ajax&sourceid=mozilla2&ie=utf-8&oe=utf-8

denizengt
March 15th, 2006, 09:53 PM
I cannot get this AJAX to work at all. All I want to do, is what I wrote above - I don't care if it needs to refresh the page to populate the fields, as its for admin use anyway. I don't want to use XML.