Revision 795,
1.0 KB
checked in by viani, 15 years ago
(diff) |
Ticket #488 - Inclusão do módulo workflow no ramo trunk do repositório Expresso.
|
Line | |
---|
1 | /** |
---|
2 | * Gets all fields that have the id starting with "_". |
---|
3 | * It's usefull when you have to validate fields with an ajax call, for example. |
---|
4 | * Returns an array of elements. |
---|
5 | */ |
---|
6 | function get_form_fields(form_id){ |
---|
7 | var elems = document.forms[form_id].elements; |
---|
8 | var arr = new Object(); |
---|
9 | var j = 0; |
---|
10 | for(var i = 0; i < elems.length; i++){ |
---|
11 | if(elems[i].id.substr(0,1) == "_"){ |
---|
12 | // if the element is a radiobutton and is NOT checked, goes to the next element |
---|
13 | if(elems[i].type == "radio" && !elems[i].checked){ |
---|
14 | continue; |
---|
15 | } |
---|
16 | |
---|
17 | if(elems[i].type == "select-multiple"){ |
---|
18 | var selectBoxMultiple = elems[i]; |
---|
19 | var selectArr = new Array(); |
---|
20 | for(k = 0; k < elems[i].length; k++){ |
---|
21 | var option = selectBoxMultiple.options[k]; |
---|
22 | if(option.selected){ |
---|
23 | if(option.value != ''){ |
---|
24 | selectArr.push(option.value); |
---|
25 | } else { |
---|
26 | selectArr.push(option.innerHTML); |
---|
27 | } |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | arr[elems[i].id] = selectArr; |
---|
32 | j++; |
---|
33 | continue; |
---|
34 | } |
---|
35 | arr[elems[i].id] = elems[i].value; |
---|
36 | j++; |
---|
37 | } |
---|
38 | } |
---|
39 | return arr; |
---|
40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.