
Problemas Com Script Em Form
#1
Posted 01/06/2006, 10:53
<script language="javascript" type="text/javascript">
function checkthis(theBox){
boxName=theBox.name;
elm=theBox.form.elements;
Total = 1; //total de checkboxes q podem ser marcados
count=0;
for(i=0;i<elm.length;i++)
if(elm[i].name==boxName && elm[i].checked==true)
count++
if(count > Total){
alert('Mais de ' + Total + ' opção(ões) marcada(s) no grupo ' + theBox.name + '.');
theBox.checked=false;
}
}
</script>
#2
Posted 01/06/2006, 15:57
#3
Posted 01/06/2006, 17:06
nao to conseguindo tornar fazer esse script funcionar. Ele deveria limitar a quantidade de checkbox que podem ser marcados.
<script language="javascript" type="text/javascript">
function checkthis(theBox){
boxName=theBox.name;
elm=theBox.form.elements;
Total = 1; //total de checkboxes q podem ser marcados
count=0;
for(i=0;i<elm.length;i++)
if(elm[i].name==boxName && elm[i].checked==true)
count++
if(count > Total){
alert('Mais de ' + Total + ' opção(ões) marcada(s) no grupo ' + theBox.name + '.');
theBox.checked=false;
}
}
</script>
for(i=0;i<elm.length;i++)
{ falta esta chave (acho!!)
if(elm[i].name==boxName && elm[i].checked==true)
{ falta esta chave (acho!!)
count++
if(count > Total){
alert('Mais de ' + Total + ' opção(ões) marcada(s) no grupo ' + theBox.name + '.');
theBox.checked=false;
}
} falta esta chave (acho!!)
} falta esta chave (acho!!)
#4
Posted 02/06/2006, 10:28

#5
Posted 02/06/2006, 10:29
so vou ter q adaptar...
#6
Posted 02/06/2006, 11:00
#7
Posted 02/06/2006, 12:41
<script language="javascript" type="text/javascript"> function checkthis(theBox){ boxName=theBox.name; elm=theBox.form.elements; Total = 1; //total de checkboxes q podem ser marcados count=0; for(i=0;i<elm.length;i++) { if(elm[i].name==boxName && elm[i].checked==true) { count++ if(count > Total){ alert('Mais de ' + Total + ' opção(ões) marcada(s) no grupo ' + theBox.name + '.'); theBox.checked=false; } } } } </script> <script language="javascript" type="text/javascript"> function mostra_exibe13(){ if(document.getElementById("teste").style.display == "none") document.getElementById("teste").style.display = "block"; else document.getElementById("teste").style.display = "none"; } </script>
<input name="tipoarquivo[1]" type="checkbox" id="tipoarquivo[1]" onclick="return mostra_exibe13();checkthis(this)" value="a5"> <input name="tipoarquivo[1]" type="checkbox" id="tipoarquivo[1]" onclick="return mostra_exibe12();checkthis(this)" value="a4"> <input name="tipoarquivo[1]" type="checkbox" id="tipoarquivo[1]" onclick="return mostra_exibe11();checkthis(this)" value="a3"> <input name="tipoarquivo[1]" type="checkbox" id="tipoarquivo[1]" onclick="return mostra_exibe10();checkthis(this)" value="a2">
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)