Hi.

I suppose this is actually 2 bugs in 1.

Firstly, Form.serialize only serializes the first input[type="submit"] button.

In Form.serializeElements(), the variable submitted is set when the
first submit button is serialized, inhibiting the serialization of
other submit buttons.

Secondly, the pressed button (if one was pressed) should be serialized.


Is there anything that can be done about this behaviour?

The only way I can think of is to add a property to the form
indicating which submit button was clicked and then serialize that
button, rather than the first one.


Having multiple submit buttons is fine according the HTML 4.01
(http://www.w3.org/TR/html401/interact/forms.html#submit-button)

Also ... "A button (and its value) is only included in the form
submission if the button itself was used to initiate the form
submission." 
(http://www.w3.org/TR/2009/WD-html5-20090212/forms.html#the-button-element)


As a consequence, submitting a form via AJAX doesn't supply the
appropriate button.

Or that is what is happening to me.

Regards,

Richard.

Example (http://pastie.org/402166) :

<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js";></script>
<script type="text/javascript">
document.observe('dom:loaded', function() {
 $('seri').observe('submit', function(ev) {
  ev.stop();
  alert($('seri').serialize());
 });
});
</script>
<body>
<div>
 <form id="seri" method="post" action="">
  <select id="aSelector" name="bob">
   <option value="1">One</option>
   <option value="2">Two</option>
   <option value="3">Three</option>
   <option value="4">Four</option>
  </select>
  <input type="submit" id="tabRG_PDF" name="tabRG_ReportType[31]"
value="Adobe Acrobat PDF" />
  <input type="submit" id="tabRG_Excel" name="tabRG_ReportType[36]"
value="Microsoft Excel Spreadsheet" />
  <input type="submit" id="tabRG_Word" name="tabRG_ReportType[14]"
value="Microsoft Word Document" />
  <input type="reset" id="tabRG_Reset" name="tabRG_Reset" value="Discard" />
 </form>
<div>
</body>
</html>

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to