A. Based on the use case you describe, it seems you may actually want  
the "onsubmit" event rather than "onclick"  (Make sure your button is  
of type submit)

B. If the form fields you're wishing to add are the only other inputs  
in the form, you can collect them with Form.serialize('idOfForm',  
true); [1]  Otherwise, do something like {email: $('email').value,  
zipcode: $('zipcode).value}

C. Pass the form fields to the 'parameters' option. [2] [3] e.x.:
new Ajax.Updater('div123', '/gotit.php', {
   method: 'get', //default is 'post'; use whichever is most  
appropriate to your situation
   parameters: Form.serialize('idOfForm', true),
   asynchronous:true,  // Default behavior.  Not needed.
   evalScripts:true
});


TAG

1. http://www.prototypejs.org/api/form#method-serialize
2. http://www.prototypejs.org/api/ajax/options
3. A side comment here to those responsible for documentation:  The  
example Ajax.Request (at http://www.prototypejs.org/api/ajax/ 
request ) doesn't use "parameters" but builds its request string  
manually.  Perhaps a different/additional example would be useful.


On Jul 6, 2007, at 8:53 AM, Scott Phillips wrote:

>
> I am firing the following event when a button is clicked...
>
>  onclick="new Ajax.Updater('div123', '/gotit.php',{asynchronous:true,
> evalScripts:true }); return false;"
>
> It all works fine, but I now need to add in some form fields when the
> button is clicked. There are two form fields, 'email' and 'zipcode'
> which i want to submit to /gotit.php when the button is clicked.... I
> can't figure out how to do it though...
>
> Do I want to change it to this:
>
>  onclick="new Ajax.Updater('div123', '/gotit.php'+ value, { ... },
> {asynchronous:true, evalScripts:true }); return false;"
>
> Thanks for any help....
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to