PHP Script that uses AJAX

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

PHP Script that uses AJAX

Post by CoolAsCarlito »

I have a drop down select box and need to know how to recall all the info that option has and have it post it's info into the form fields below it. How is that done. Because it'll give the user the ability to edit the info and then click "Update" and it'll change the info.

http://www.kansasoutlawwrestling.com/edittitle.php

I was told this would help but I'm still clueless. Someone with an intelligent mind please help me please:

You need AJAX for that. The drop down menu would need an onchange="ajax_function()" inside of the <select> tag. You would have to define ajax_function() as a javascript function elsewhere in the document.

Essentially how it works is this (extremely simplified): the ajax/javascript function that is called from onchange will check what the current selected value in the menu is and send it as a parameter to a .php file. The php file retrieves the parameter with the $_POST or $_GET arrays. The file pulls what ever info you need from the database, formats it, and gives it back to the javascript function. The javascript function then sets some other div's inner HTML to whatever was retrieved from the php file.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: PHP Script that uses AJAX

Post by ghurtado »

Do you have any javascript experience?
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: PHP Script that uses AJAX

Post by CoolAsCarlito »

I know how to read it but I don't understand it enough to write it.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: PHP Script that uses AJAX

Post by ghurtado »

In that case, jumping straight into AJAX without any previous Javascript experience might prove an insurmountable task for you. Do you have any previous programming experience in any language?
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: PHP Script that uses AJAX

Post by CoolAsCarlito »

HTML and PHP
Post Reply