Jump to content


Photo

Help!


  • Please log in to reply
6 replies to this topic

#1 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 29 March 2006 - 06:07 PM

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).

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 29 March 2006 - 06:15 PM

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.

Info: PHP Manual


#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 29 March 2006 - 06:44 PM

[!--quoteo(post=359754:date=Mar 29 2006, 01:15 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 29 2006, 01:15 PM) View Post[/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.

#4 AshAsirus

AshAsirus
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 March 2006 - 07:01 PM

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.

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 29 March 2006 - 08:16 PM

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.

Info: PHP Manual


#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 29 March 2006 - 08:24 PM

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


#7 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 29 March 2006 - 08:31 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users