hi, i''m not sure if this has already been discussed, but the forum
interface search facility isn''t working due to ''technical
difficulties''
and i can''t find anything about it in google.
in Form.serialize there is nothing to tell you what button was clicked for
a submit event. i''ve made the following change to prototype.js:
var form_submit_button_used = false;
var Form = {
serialize: function(form) {
var elements = Form.getElements($(form));
var queryComponents = new Array();
for (var i = 0; i < elements.length; i++) {
var add_to_query = true;
if(elements[i].type=="submit")
{
if((elements[i].name!=form_submit_button_used)||(!form_submit_button_used))
add_to_query = false;
}
if(add_to_query)
{
var queryComponent = Form.Element.serialize(elements[i]);
if (queryComponent)
queryComponents.push(queryComponent);
}
}
in order to use this, you have to set the form_submit_button_used variable
to the name of the button that was clicked. i have implemented this
function elsewhere, but it may be good to write a method called
Form.prepareClickEvents or something like that so that it''s bundled as
part of prototype:
forms = document.forms;
for(i = 0;i<forms.length;i++)
{
for(j = 0;j < forms[i].elements.length;j++)
{
var curr = forms[i].elements[j];
if(curr.type == "submit")
curr.onclick = setSubmittedName;
}
}
function setSubmittedName()
{
form_submit_button_used = this.name;
}
cheers
iain