Hi js_dev, this group discuss about prototype core development. I repost this message on the good group.
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/4888a6a8031c04c9?hl=fr -- david On 31 mai, 20:18, js_dev <smac5...@hotmail.co.uk> wrote: > Hello, > > I have a function i found on the web that allows you to submit a form > through POST and obviously this function uses the prototype lib. Now > it works as it should but you have to "hard code" 3 parameters into > the function. > > 1) The form id of the form you want to post > 2) The name of the php script that the form/ajax is posted too > 3) The name of the html element that you want the ajax reposnsetext > set into. > > Can i make this function more generic so that i can pass the above 3 > parameters to the function from the html. In In the said function > (below),the hard coded paramaters are contactForm, feedback and > login.php. So this listener function wathces for a form click on the > form with id = contactForm etc...and then grabs the form POST data, > but as i said what if i have more than one form with different ids, > different output elements and different php scripts, > > document.observe('dom:loaded', function() { > > function sendForm(event){ > // we stop the default submit > behaviour > Event.stop(event); > var oOptions = { > method: "POST", > parameters: > Form.serialize("contactForm"), > asynchronous: true, > onFailure: function > (oXHR) { > > $('feedback').update(oXHR.statusText); > }, > > onSuccess: > function(oXHR) { > > $('feedback').update(oXHR.responseText); > } > }; > var oRequest = new > Ajax.Updater({success: > > oOptions.onSuccess.bindAsEventListener(oOptions)}, "login.php", > oOptions); > } > Event.observe('submitButton', > 'click', sendForm, false); > > }); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---