Ruby Forum Rails Spinoffs > passing multiple form elements to Ajax.Request

Posted by McBlaue (Guest)
on 13.05.2008 08:03
(Received via mailing list)
Hi I'm a newbie to AJAX and prototype and am writing a simple
application that calculates some figures in php given some variables
from a form, and display the outcome in a DIV. I can get it to
function using a single parameter like this:

function doSums()  {
  new Ajax.Updater('fruits', 'calculator2.php', { method: 'post',
parameters: salary=$('salary').serialize(true) });
  return false;
  }

but I can't pass more than 1 form element. I have tried:

parameters: salary=$('salary'), age=$('age').serialize(true)

and

parameters: $F('salary'), $F('age').serialize(true)
Posted by McBlaue (Guest)
on 13.05.2008 08:05
(Received via mailing list)
Apologies: I am using prototype.js
Posted by McBlaue (Guest)
on 13.05.2008 10:44
(Received via mailing list)
I also have tried this but no go:

new Ajax.Updater('fruits', 'calculator2.php', { method: 'post',
parameters: Form.serialize(this) });
Posted by McBlaue (Guest)
on 13.05.2008 11:14
(Received via mailing list)
The answer is this (I was close, just needed to be more  specific):

new Ajax.Updater('fruits', 'calculator2.php', { method: 'post',
parameters: form1.serialize() });