Jump to content

Archived

This topic is now archived and is closed to further replies.

hostfreak

Help!

Recommended Posts

Hello everyone, Im trying to do something that involves php/mysql. Anyways I cant really explain what I want to do so I have made an example:

[a href=\"http://www.gameflaw.com/misc/example.html\" target=\"_blank\"]http://www.gameflaw.com/misc/example.html[/a]

What I want is say someone selects a name from the dropdown, the information to fill into the fields below it (state, city, zip, phone etc) depending on the information in the database for that name. Can anyone help me with this? Or lead me towards the right direction to getting this done (tutorial, website etc).

Share this post


Link to post
Share on other sites
There are 2 ways to do this:

1) in the onchange event of the select box, you call a javascript function that recalls the page with the ID of the user selected and runs the PHP to fill the boxes.
2) You use AJAX to do the dirty work.

Both require Javascript. If you want to avoid Javascript, you'll have to use 2 different forms. One with just the select box and one to deal with the info in the other fields once they get filled in.

Share this post


Link to post
Share on other sites
[!--quoteo(post=359754:date=Mar 29 2006, 01:15 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 29 2006, 01:15 PM) [snapback]359754[/snapback][/div][div class=\'quotemain\'][!--quotec--]
There are 2 ways to do this:

1) in the onchange event of the select box, you call a javascript function that recalls the page with the ID of the user selected and runs the PHP to fill the boxes.
2) You use AJAX to do the dirty work.

Both require Javascript. If you want to avoid Javascript, you'll have to use 2 different forms. One with just the select box and one to deal with the info in the other fields once they get filled in.
[/quote]


I don't mind using javascript. On the javascript im not sure what function to call? The ID of the user won't be located on any page (I guess just the edit page however) but other than that just in a the mysql database. Im not sure if it makes sense what im asking? Im new to php so please bear with me. And thanks for the reply.

Share this post


Link to post
Share on other sites
couldn't you populate the Select Box with the names from your DB and give them the VALUE of the person ID. then on change simply submit the form grab the info based off the id and set them as vars ... then simply set the value of each input box to the apporiate var.

Share this post


Link to post
Share on other sites
Ash is right, but you should be able to query your database on both the username and the ID. If you want more info about the AJAX solution, I suggest you head over to ajaxfreaks.com.

Share this post


Link to post
Share on other sites
I've got the dropdown querying the users now I just need to get it to change the information in other fields depending on what user is selected. I will look for the JavaScript see what I can find. If not then I will look into Ajax, but i'm not familiar with it

Share this post


Link to post
Share on other sites
AJAX is pretty easy to use once you get used to it. The coding is pretty simple, it's the concept that you have to wrap your head around and what your limitations are.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.