Boa tarde meu povo, acabei de me cadastrar neste fórum para tirar uma dúvida! Não sei se vou contra às regras, e peço desculpas se estiver! :rolleyes: Mas vamos à dúvida! Estou criando um formulário para orçamento da gráfica onde trabalho, sendo que todos os campos contém um valor pré-determinado que será somado no final da página. Porém, neste exemplo que vou postar abaixo, não consigo fazer aparecer mais do que 1 checkbox com o valor. :wacko: <html>
<head>
</head>
<body>
<form>
<script LANGUAGE="JavaScript">
<!--
function checkChoice(whichbox) {
with (whichbox.form) {
if (whichbox.checked == false)
hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value);
else
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value);
return(formatCurrency(hiddentotal.value));
}
}
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);
num = Math.floor((num*100+0.5)/100).toString();
if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
return ("R$" + num + "." + cents);
}
// -->
</script>
<p>Teste clicando aqui <INPUT TYPE="checkbox" ONCLICK="document.all.mostraBox.style.display =
(document.all.mostraBox.style.display == 'none') ? '' : 'none'; document.all.mostraTexto.style.display =
(document.all.mostraTexto.style.display == 'none') ? '' : 'none'">
<BR>
<font style="display:none" color="black" id="mostraTexto"> campo:</font>
<INPUT TYPE="checkbox" STYLE="display:none" ID="mostraBox" name="campo1" value="10.00"
onClick="this.form.total.value=checkChoice(this);">
<br>
Total: <input type="text" name="total" value="" size=6 readonly><input type=hidden name=hiddentotal value=0>
</form>
</body>
</html> Se vocês souberem me ajudar, ficarei grato! :lol: Obrigado por enquanto! :rolleyes: