Jump to content

Help!


hostfreak

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).
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.