selecao_listbox.js
6.95 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<SCRIPT LANGUAGE="JavaScript">
function valida_form()
{
for (i=0;i<document.forma.elements.length;i++)
{
if (document.forma.elements[i].name == "list2" && document.forma.elements[i].length <= 0 && document.forma.elements[i].cs_situacao[1].checked)
{
alert("Você deve selecionar ao menos uma rede.");
return false;
}
else if (document.forma.elements[i].name == "list4" && document.forma.elements[i].length <= 0)
{
alert("Você deve selecionar ao menos um sistema operacional.");
return false;
}
else if (document.forma.elements[i].name == "list9" && document.forma.elements[i].length <= 0)
{
alert("Você deve selecionar ao menos um aplicativo.");
return false;
}
else return true;
}
return true;
}
function verifica_status() {
for (i=0;i<window.document.forms.length;i++)
{
for (j=0;j<window.document.forms[i].elements.length;j++)
{
if (window.document.forms[i].elements[j].name == 'list1[]')
{
if (document.forma.elements.cs_situacao[1].checked)
{
document.forma.elements['list1[]'].disabled=false;
document.forma.elements['list2[]'].disabled=false;
document.forma.elements['B1'].disabled=false;
document.forma.elements['B2'].disabled=false;
}
else
{
document.forma.elements['list1[]'].disabled=true;
document.forma.elements['list2[]'].disabled=true;
document.forma.elements['B1'].disabled=true;
document.forma.elements['B2'].disabled=true;
}
}
}
}
}
function copia(fbox,tbox)
{
// tbox.options.length=0;
for(var i=0; i<fbox.options.length; i++)
{
if(fbox.options[i].selected && fbox.options[i].value != "")
{
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
}
}
ordena(tbox);
}
function ordena(box)
{
for (i=box.options.length-1; i>=0; i--)
{
for (j=0; j<box.options.length-1; j++)
{
if (box.options[j].text > box.options[j + 1].text)
{
Ttext = box.options[j].text;
Tvalue = box.options[j].value;
box.options[j].text = box.options[j + 1].text;
box.options[j].value = box.options[j + 1].value;
box.options[j + 1].text = Ttext;
box.options[j + 1].value = Tvalue;
}
}
}
return box;
}
function exclui(fbox,tbox) {
for(var i=0; i<tbox.options.length; i++)
{
for(var j=0; j<fbox.options.length; j++)
{
if(fbox.options[j].selected && fbox.options[j].value != "")
{
if (tbox.options[i].value == fbox.options[j].value && tbox.options[i].text == fbox.options[j].text)
{
tbox.options[i].value = "";
tbox.options[i].text = "";
}
}
}
}
BumpUp(tbox);
ordena(tbox);
}
function move(fbox,tbox)
{
//MostraLayer('layerAguarde');
for(var i=0; i<fbox.options.length; i++)
{
if(fbox.options[i].selected && fbox.options[i].value != "")
{
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
//EscreveNaLayer('layerAguarde','Movendo "'+no.text+'"');
}
}
BumpUp(fbox);
ordena(tbox);
//EscondeLayer('layerAguarde');
}
function BumpUp(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].value == "") {
for(var j=i; j<box.options.length-1; j++) {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
}
}
if(ln < box.options.length) {
box.options.length -= 1;
BumpUp(box);
}
}
function SelectAll(combo)
{
var seleciona = true;
for (var i=0;i<combo.options.length;i++)
{
if (combo.name=='list8[]')
{
var texto = combo.options[i].text;
if ((texto.indexOf("Data/Hora"))!=-1)
{
seleciona = false;
}
}
combo.options[i].selected=seleciona;
seleciona = true;
}
}
// Para uso da opção "Todas as redes" ou "Apenas redes selecionadas"
function ChecaTodasAsRedes()
{
for (intForms=0;intForms<window.document.forms.length;intForms++)
{
for (intElements=0;intElements<window.document.forms[intForms].elements.length;intElements++)
{
if (document.forms[intForms].elements[intElements].name == 'cs_situacao' &&
document.forms[intForms].elements[intElements].value == 'T' &&
document.forms[intForms].elements[intElements].checked == true)
{
SelectAll(document.forms[intForms].elements['list1[]']);
move(document.forms[intForms].elements['list1[]'],document.forms[intForms].elements['list2[]']);
SelectAll(document.forms[intForms].elements['list2[]']);
document.forms[intForms].elements['list2[]'].disabled=false;
intElements = window.document.forms[intForms].elements.length;
}
}
}
return true;
}
// As funções abaixo são para uso da seleção de critérios para relatório patrimonial
function Preenche_Condicao_VAZIO(p_campo)
{
for (i=0;i<window.document.forms.length;i++)
{
for (j=0;j<window.document.forms[i].elements.length;j++)
{
if (window.document.forms[i].elements[j].name == p_campo)
{
window.document.forms[i].elements[j].value = "<VAZIO>";
window.document.forms[i].elements[j].disabled = true;
}
}
}
}
function Verifica_Condicoes_Seta_Campo(p_campo)
{
for (i=0;i<window.document.forms.length;i++)
{
for (j=0;j<window.document.forms[i].elements.length;j++)
{
if (window.document.forms[i].elements[j].name == p_campo && window.document.forms[i].elements[j].value == "<VAZIO>")
{
window.document.forms[i].elements[j].value = '';
window.document.forms[i].elements[j].disabled = false;
}
}
}
SetaCampo(p_campo);
}
function Verifica_Selecao(p_campo,p_campo_selecao)
{
if (p_campo.value == '')
{
for (i=0;i<window.document.forms.length;i++)
{
for (j=0;j<window.document.forms[i].elements.length;j++)
{
if (window.document.forms[i].elements[j].name == p_campo_selecao)
{
window.document.forms[i].elements[j].value = '';
}
}
}
}
}
function Valida_Form_Pesquisa(p_argumento)
{
var v_conteudo = '';
var v_tamanho = 0;
v_tamanho = p_argumento.length;
for (i=0;i<window.document.forms.length;i++)
{
for (j=0;j<window.document.forms[i].elements.length;j++)
{
if (window.document.forms[i].elements[j].name.substring(0,v_tamanho) == p_argumento &&
window.document.forms[i].elements[j].value != '')
{
v_conteudo = v_conteudo + window.document.forms[i].elements[j].value;
}
}
}
if (v_conteudo == "")
{
alert("É necessário informar ao menos uma condição para pesquisa!");
return false;
}
return true;
}
</script>