...

View Full Version : I want to build an calculator calculates Apt rates



lse123
06-09-2008, 06:18 PM
I want to build an calculator calculates Apt rates (3 adult apt: 2adults=euro41 _ additional adult=euro6 (1 adult same as two) AND air/condition euro6/apt/day), below code is correct ?
Form At: http://www.holidayaptsaspasia.com/bookingapt.html

head:

<script type="text/javascript">
function calc() {
if (document.book.ac.checked == true) {
ac = 6;
} else {
ac = 0;
}
document.book.euro.value = document.book.days.value * (floor((document.book.adults.value)/3) * (47+ac) + 41 + ac) ;
}
</script>

body:

<tr>
<th width="164" height="35" align="right" valign="middle" scope="col"><div align="right">No.
of Apts Interested:</div></th>
<th width="361" align="center" valign="middle" scope="col"><table width="100%" border="0" cellspacing="0" cellpadding="3" summary="javascript calculator euros total">
<tr>
<td width="12%" align="left" valign="middle"><input name="aptno" type="text" id="aptno" value="1" size="1" maxlength="1" onchange="calc();" /></td>
<td width="35%" align="right" valign="middle">No. of Days to Stay:</td>
<td width="15%" align="left" valign="middle"><input name="days" type="text" id="days" value="0" size="2" maxlength="2" onchange="calc();" /></td>
<td width="15%" align="right" valign="middle" bgcolor="#CCCCCC" class="text_normal"><strong>Total(€):</strong></td>
<td width="23%" align="left" valign="middle" bgcolor="#CCCCCC"><input name="euro" type="text" disabled="disabled" class="text_normal_bold_red" id="euro" value="0" size="6" maxlength="6" /></td>
</tr>
</table></th>
</tr>
<tr>
<th height="25" align="center" valign="middle" scope="col">(3 adults
per Apt)</th>
<th align="center" valign="middle" scope="col"><table width="100%" border="0" cellspacing="0" cellpadding="3" summary="javascript calculator euros total">
<tr>
<td width="25%" align="right" valign="middle">No. of Adults:</td>
<td width="16%" align="left" valign="middle"><input name="adults" type="text" id="adults" value="2" size="2" maxlength="2" onblur="calc();" /></td>
<td width="27%" align="right" valign="middle">Air Contition:</td>
<td width="32%" align="left" valign="middle"><input name="ac" type="checkbox" class="text_normal" id="ac" onblur="calc();" checked="checked" /></td>
</tr>
</table></th>
</tr>

lse123
06-09-2008, 06:19 PM
I must use onblur or onchange to the js calc ?

Philip M
06-09-2008, 06:37 PM
562 posts, 0 thanks.

This guy is a web developer and is being paid for his work output.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum