PDA

View Full Version : there's a calculator I do not see to work , can you help ?



leonidassavvides
06-12-2008, 04:34 PM
js Q:
there's a calculator on booking form at
http://www.holidayaptsaspasia.com/bookingapt.html
I do not see to work , can you help ?
design Q:
Also menu on top I want it (and I setup it right alignment) why exist some distance ?

leonidassavvides
06-12-2008, 10:50 PM
Also do NOT work the onsubmit="return submitForm();" (same page) ? check source...
the onreset work .

leonidassavvides
06-15-2008, 06:16 PM
code below is for calculator at(body):

<input type="button" name="button6" id="button6" value="Calculate Total" onclick="calc();"/>
is it correct ?
head:

<title>Booking Form</title>
<script type="text/javascript">
function calc() {
if (document.book.ac2.checked == "true") { // does not work either with == true
var ac = 6;
} else {
ac = 0;
}
// ac = 6; if (parseInt(document.book.month.value) > 3 && parseInt(document.book.month.value) < 11) {

if ((document.book.month.value) > 3 && (document.book.month.value) < 11) {
var rate = 41; // rate for two Summer
} else {
rate = 35;
}
if (parseInt(document.book.adults.value % 3) == 0) {
var not3 = 0;
} else {
not3 = 1;
}
var tsp1 = new Date(document.book.year.value,document.book.month.value-1,document.book.day.value);
var tsd1 = new Date(document.book.toyear.value,document.book.tomonth.value-1,document.tobook.day.value);
var tsp = tsp1.getTime();
var tsd = tsd1.getTime();
// tsp = tsp1.valueOf();
// tsd = tsd1.valueOf();
var days1;
days1 = ($tsd - $tsp)/(24*60*60);
// document.book.euro.value = 99;
document.book.days.value = days1; //days1
var eurocost = days1 * (Math.floor(parseFloat(document.book.adults.value) / 3) * (6 + rate + ac) + not3 * (rate + ac));
// document.book.euro.value = days1 * (Math.floor(parseFloat(document.book.adults.value) / 3) * (6 + rate + ac) + not3 * (rate + ac));
document.book.euro.value = eurocost;
alert(days1);
alert(eurocost);
//x = floor((document.book.adults.value)/3)
//document.book.euro.value = document.book.days.value * (x * (47+ac) + 41 + ac) ;
}
</script>

code below is for the onsubmit="return submitForm();" (same page) , does not work ?


function submitForm() {
if (document.book.email.value == "") {
window.alert("You must enter your email address to submit form!");
return false;
}
var startDate = new Date(document.book.year.value,document.book.month.value-1,document.book.day.value); // var startDate = new Date(document.forms[0].year.value,document.forms[0].month.value,document.forms[0].day.value);
var endDate = new Date(document.book.toyear.value,document.book.tomonth.value-1,document.book.today.value); // var endDate = new Date(document.forms[0].toyear.value,document.forms[0].tomonth.value,document.forms[0].today.value);

if (startDate.getTime() > endDate.getTime()) { // startDate.valueof() > endDate.valueof()
window.alert("You must enter Start Date prior End Date to submit form!");
return false;
}
else
return true;
} // end function p261 gosselin book
</script>