hostfreak Posted March 29, 2006 Share Posted March 29, 2006 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). Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/ Share on other sites More sharing options...
ober Posted March 29, 2006 Share Posted March 29, 2006 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 Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22040 Share on other sites More sharing options...
hostfreak Posted March 29, 2006 Author Share Posted March 29, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22048 Share on other sites More sharing options...
AshAsirus Posted March 29, 2006 Share Posted March 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22051 Share on other sites More sharing options...
ober Posted March 29, 2006 Share Posted March 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22076 Share on other sites More sharing options...
hostfreak Posted March 29, 2006 Author Share Posted March 29, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22082 Share on other sites More sharing options...
ober Posted March 29, 2006 Share Posted March 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6116-help/#findComment-22086 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.