Autor Zpráva
senior
Profil
Príjemný deň,
prosím o pomoc. Nedarí sa mi už pár dní sfunkčniť script na tejto stránke - nefunguje totalcost2. V JS som začiatočník. Ďakujem za každú radu.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>rezervačný systém</title>
<meta name="recource-type" content="document">
<meta name="distribution" content="local">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<script type="text/javascript">
// funkcia na kalkulaciu cien
function Total() {
var tot = 0;
tot += (70.00 * document.order.qty1.value);
tot += (50.00 * document.order.qty2.value);
tot += (30.00 * document.order.qty3.value);
tot += (70.00 * document.order.qty4.value);
tot += (90.00 * document.order.qty5.value);
tot += (70.00 * document.order.qty6.value);
tot += (120.00 * document.order.qty7.value);
tot += (50.00 * document.order.qty8.value);
tot += (40.00 * document.order.qty9.value);
tot += (70.00 * document.order.qty10.value);
document.order.totalcost.value = tot;
document.order.totalcost2.value = tot*noc;
}

// funkcia na update cien pri zmene
function UpdateCost(number, unitcost) {
costname = "cost" + number;
qtyname = "qty" + number;
var q = document.order[qtyname].value;
document.order[costname].value = q * unitcost;
Total();
}
</script>
</head>
<body>
<div style="text-align: center; font-weight: bold; margin: 5px auto 0px auto">záväzne si rezervujem ubytovanie</div>
<form name="order" method="POST" action="http://www.mailform.cz/form.asp" onSubmit="return overit(this)">
<input type="hidden" name="mailform_userid" value="50291">
<table width="465" align="center" cellspacing="0" cellpadding="2" border="0" style="margin: 5px auto 0px auto">
<tr style="background-color: #F9F9F9"><td width="35%">od <input type="text" name="datumod" size="10" style="text-align: right"></td><td width="35%">do <input type="text" name="datumdo" size="10" style="text-align: right"></td><td width="30%">počet nocí <input type="text" name="noc" size="2" value="" style="text-align: right"></td></tr>
</table>
<table width="465" align="center" cellspacing="0" cellpadding="2" border="0" style="margin: 5px auto 0px auto">
<tr style="font-weight: bold; background-color: #F9F9F9"><td width="60%">položka/noc</td><td width="15%" style="text-align: right">cena Sk</td><td width="10%" style="text-align: center">počet</td><td width="15%" style="text-align: center">suma Sk</td></tr>
<tr><td>osoba</td><td style="text-align: right">70,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty1" value="0" size="3" onChange="UpdateCost(1, 70.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost1" size="8" style="text-align: right"></td></tr>
<tr><td>dieťa do 12 rokov</td><td style="text-align: right">50,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty2" value="0" size="3" onChange="UpdateCost(2, 50.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost2" size="8" style="text-align: right"></td></tr>
<tr><td>pes</td><td style="text-align: right">30,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty3" value="0" size="3" onChange="UpdateCost(3, 30.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost3" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - stan</td><td style="text-align: right">70,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty4" value="0" size="3" onChange="UpdateCost(4, 70.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost4" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - karavan</td><td style="text-align: right">90,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty5" value="0" size="3" onChange="UpdateCost(5, 90.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost5" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - osobné auto</td><td style="text-align: right">70,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty6" value="0" size="3" onChange="UpdateCost(6, 70.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost6" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - obytné auto</td><td style="text-align: right">120,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty7" value="0" size="3" onChange="UpdateCost(7, 120.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost7" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - prívesný vozík</td><td style="text-align: right">50,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty8" value="0" size="3" onChange="UpdateCost(8, 50.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost8" size="8" style="text-align: right"></td></tr>
<tr><td>miesto - motocykel</td><td style="text-align: right">40,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty9" value="0" size="3" onChange="UpdateCost(9, 40.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost9" size="8" style="text-align: right"></td></tr>
<tr><td>elektr. prípojka 220 V</td><td style="text-align: right">70,00&nbsp;&nbsp;</td><td style="text-align: center"><input type="text" name="qty10" value="0" size="3" onChange="UpdateCost(10, 70.00);" style="text-align: right"></td><td style="text-align: center"><input type="text" name="cost10" size="8" style="text-align: right"></td></tr>
<tr style="font-weight: bold; background-color: #F9F9F9"><td colspan="3">celková suma za ubytovanie/noc</td><td style="text-align: center"><input type="text" name="totalcost" size="8" style="text-align: right"></td></tr>
<tr style="font-weight: bold; background-color: #F9F9F9"><td colspan="3">celková suma za ubytovanie</td><td style="text-align: center"><input type="text" name="totalcost2" size="8" style="text-align: right"></td></tr>
</table>
</form>
</body>
</html>
Chamurappi
Profil
Reaguji na seniora:
document.order.totalcost2.value = tot * document.order.noc.value;
peta
Profil
senior
viz Ch, mas to v JS konzole, na kterem radku mas chybu.
FF: nastroje - chybova konzola
O: nastroje - js konzola
IE: dole ve status bud modre "e" nebo zluty vykricnik
jinak bych si pojmenoval na zacatku
var f= document.order;
a pekne se ti to zprehledni.
senior
Profil
Chamurappi
peta
Vďaka obom za pomoc.

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0