blob: 70c9ae00238005420a5f19caabea10c17a25b7f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/**
* (C) Thomas 'PointedEars' Lahn, 2009, released under GPLv3
*
* Retrieves the data to send in the request, and optionally the request
* method, from an (X)HTML form. TODO: select[multiple] elements
*
* @param f : HTMLFormElement
* @param bUseFormMethod: optional boolean
* If <code>true</code>, the form's request method becomes the
* <code>HTTPRequest</code> object's request method. The default
* is <code>false</code>.
* @return boolean
*/
getDataFromForm = function(f, bUseFormMethod) {
var result = false, es, len;
if (f && (es = f.elements) && (len = es.length))
{
if (bUseFormMethod) this.method = f.method;
var aData = [];
for (var i = 0; i < len; i++)
{
var o = es[i];
if (o.name)
{
aData.push(esc(o.name) + "=" + esc(o.value != "" ? o.value : ""));
}
}
this.data = aData.join("&");
result = true;
}
return result;
};
|