RE: [Fwd] Proposal of DOM method query()

Dear Nikodem,

Thank you for forwarding your message to www-dom to us here.  We
discussed your message at the Forms Working Group teleconference today
and I'm giving you the response from the XForms perspective.

XForms already handles the use case of multiple submit buttons causing
either (1) different submission locations or (2) different submitted
values, with no JavaScript required.

I've attached two files, each directly addressing your use case, using
these two solutions.  I have tested both in the Mozilla Firefox XForms
Add On, available at https://addons.mozilla.org/en-US/firefox/addon/824
though the examples should work in other XForms processors.


Submit1.xhtml:
This file uses multiple submission elements, each with its own unique
action, but each with the same submitted data.
I've tried this file out and it's able to submit directly to Google,
Yahoo, and AltaVista, though you may need to change security settings on
Firefox XForms AddOn to allow schema:file to to post data to other
servers, as most web browsers prevent submissions from forms not from
the same server.

Submit2.xhtml
This file again uses multiple submission elements, but each submits to
the same server, which could be the same server that provides the
original form, obviating any security preference changes.  The
submissions all have the same action as well, but each uses the XML
Events system to handle the xforms-submit event sent to the submission
by the submit button, and sets the "engine" value to 1, 2, or 3,
depending on which submit button was pressed.  The test site used for
the submission action just echoes back the query string, though in your
application you would probably perform some server side processing and
end with an HTTP redirect to a new location.

Please write back if you have any questions.

Leigh.

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Nikodem
Sent: Friday, October 12, 2007 4:51 AM
To: www-forms@w3.org
Subject: [Fwd] Proposal of DOM method query()


From: Nikodem <nikn1@gazeta.pl>
Date: Thu, 11 Oct 2007 19:13:48 +0200
Message-ID: <470E59CC.7060904@gazeta.pl>
To: www-dom@w3.org
Subject: [HTML DOM] Proposal of method query() in HTMLFormElement

I've had many problems with AJAX-ing forms that more than one <button
type="submit">. It can't be handled through onsubmit with
form.elements[0] etc. without such idiotisms like onclick on every
button.

I propose method query() that'd return query string
(application/x-www-urlencoded).

I.e.:

<form onsubmit="alert(this.query())" action="search.php" method="get">
<input type="text" name="search" />
<button type="submit" name="engine" value="1">Google</button>
<button type="submit" name="engine" value="2">Yahoo!</button>
<button type="submit" name="engine" value="3">AltaVista</button>
</form>

<!-- search=xxx&engine=2 -->

interface HTMLFormElement : HTMLElement {
/* ... */
DOMString query()
/* ... */
}

Received on Wednesday, 17 October 2007 18:23:22 UTC