This is a quick little tip on how to pass more than one Form Element to the Ajax.Updater function in Prototype.
This came about because I wanted to do a form POST and not a GET with several Form fields but the only documentation on the internet explained how to send ONE Form field.
It's very simple but it took me a while to really get it right.
Here is a snippet:
This code is using the Ajax.Updater to send a POST to a php page with 3 form fields to be processed. As an added tip I am sending my request to a page and I am using a URL Parameter to tell that page which function to run: myparam=save_item.
On the server side I am getting the form fields from the POST:
First I am getting the URL parameter to set which select case to run using the $_GET['myparam'].
Then I am stepping into the select statement and getting the 3 form fields from the _POST.
Now I have the values from the form all posted to the server using an Ajax.Updater.
Heres the full code:
Client Side:
Server side:
This code is stripped right down but you get the gist of it. Once you've got the values form the POST you could insert them into a data base and then return a status message.
You could also create several case statmenst for doing database operations for Select, Insert, Update and Delete.
Hola faretaste
mekodinosad
That was really great and helpful. I had the same problem. thank you very much.