Hi all
A piece for another student i’m helping. Basically it’s a flight form - it simply needs to check how many tickets have been purchased if the appropriate checkbox is also checked, then add the values together depending on the prices as declared as vars, and by the number of tickets for each.
The payment method doesn’t matter.
So basically the sub total button, when clicked, should output a figure. GST should basically give 10% of the final figure, and then the third button should add that GST on top of the subtotal.
The final button should print the results to a new page.
Dead simple really, but the existing code is mush. I’d like to leave it intact, i’m pretty sure there’s only some minor things missing.
Anyone able to help out?
Cheers
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<!-- Minus AutoDato -->
<TITLE>Jumping Kangaroo Travels</TITLE>
<META NAME="Generator" CONTENT="Stone's WebWriter 3.5">
<style type="text/css">
.body_table {
border-color: #cccccc;
border-style: solid;
border-width: 1px;
border-collapse: collapse;
padding: 10px;
width: 300px;
background: url(sky.jpg) no-repeat;
background-color: #AEDAFF;
}
.fable {
border-color: #cccccc;
border-style: solid;
border-width: 1px;
border-collapse: collapse;
width: 300px;
}
</style>
<script type="text/javascript">
<!-- Hide from incompatible browser
//variables declairation
var syd_pri= 200;
var bris_pri= 400;
var ade_pri= 200;
var perth_pri= 600;
var laun_pri= 200;
var hob_pri= 250;
var sub_tot = 0;
var gst = 0;
var tot= 0;
var pay_type = "none";
var dstn_lctn = "none";
//Selecting payment Method
function selectpay_meth()
{
if(document.forms[0].pay[0].checked == true){
Pay_type = "Cash";
}
if(document.forms[0].pay[1].checked == true){
pay_type = "Credit Card";
}
if(document.forms[0].pay[2].checked == true){
pay_type = "Cheque";
}
if(document.forms[0].pay[3].checked == true){
pay_type = "EFTPOS";
}
}
// Selecting Destination Locations
function destintion(){
var count = 0;
dstn_lctn = "";
}
//Calculate Holiday cost
function calcsub_tot(){
var sub_tot = syd_pri + bris_pri + ade_pri + perth_pri + laun_pri + hob_pri;
document.forms[0].calculate.value = "$"+ sub_tot;
}
// Calculating GST
function calcgst(){
var gst = sub_tot * 10/100
}
// Calculating Total cost
function calctot(){
var tot = sub_tot + gst
}
//confirm My Next Holiday Trip
function confirmholiday(){
var newWin = window.open();
newWin.document.write("<p><h2><font color=red>Confirmation Of your Next Holiday: </font></h2></p>");
newWin.document.write("<p><h4><font color=blue>Destinations: " + dstn_lctn + "</font></h4></p><br />");
newWin.document.write("<p><h4><font color=blue>Payment Method: " + pay_type + "</font></h4></p><br />");
newWin.document.write("<p><h4><font color=blue>Sub total: $" + parseInt(sub_tot) + "</font></h4></p><br />");
newWin.document.write("<p><h4><font color=blue>GST: $" + parseInt(gst) + "</font></h4></p><br />");
newWin.document.write("<p><h4><font color=blue>Total Cost: $" + parseInt(tot) + "</font></h4></p><br />");
//Stop hiding from incompatible browser-->
}
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {
//reloads the window if Nav4 resized
if (init==true) with (navigator) {
if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);
//-->
</script>
</HEAD>
<BODY >
<CENTER>
<div width="300" class="body_table">
<form action="FormProcessor.html" method="get" >
<br><br><br>
<P><h1 align="left"><font color="#FFFFFF">Jumping Kangaroo Travels</font></H1></P>
<HR SIZE="1"/>
<SCRIPT type=text/javascript>
<!--hide from the incompatible browsers
function curTime() {
var now = new Date();
var day = now.getDay();
var date = now.getDate();
var year = now.getFullYear();
var month = now.getMonth();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var days = new Array();
days[0] = "Sunday"; day[1] = "Monday"; days[2] = "Tuesday";
days[3] = "Wednesday"; days[4] = "Thursday"; days[5] = "Friday";
days[6]="Saturday";
var months = new Array();
months[1] = "January"; months[2] = "February"; months[3] = "March";
months[4] = "April"; months[5] = "May"; months[6] = "June";
months[7] = "July"; months[8] = "August"; months[9] = "September";
months[10] = "October"; months[11] = "November"; months[12] = "December";
var display = days[day] + " , " + date + " " + months[month] + " " + year + " , "+ hours + ":" + minutes + ":" + seconds;
document.forms[0].readout.value = display;
}
var tick = setInterval("curTime()", 1000);
//stop hiding from the incompatible browsers-->
</SCRIPT>
</CENTER>
<FORM action="">
<P><INPUT size=30 name=readout></P></FORM></BODY></HTML>
<DIV STYLE="text-align:center">
<b><h2><b>
<font>
</font></b></h2></DIV>
</br>
</p>
<tr>
<td >
<h4>
To Organize your next holiday fill in the following information: <br><br>
<font>Select Your Destination and indicate the number of tickets you require:-</font></h4></td></tr>
<table WIDTH="100%" BORDER="1px" font="arial" size="10" valign="center" class="fable">
<tr>
<td >
<font><b> Destination - Number Of Tickets
</b></font></p></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Sydney" onclick="destintion(this);" />Sydney :-
<input type="text" name="num_tick_syd" size="10" /></p></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Brisbane" onclick="destination(this);" />
Brisbane :- <input type="text" name="num_tick_bris" size="10" />
</p></td></tr></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Adelaide" onclick="destintion(this);" />
Adelaide :-<input type="text" name="num_tick_Ade" size="10" />
</p></td></tr></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Perth"
onclick="destintion(this);" />Perth :- <input type="text" name="num_tick_per" size="10" /></p></td></tr></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Launceston "
onclick="destintion(this);" />Launceston:-<input type="text" name="num_tick_laun" size="10" /></p></td></tr></td></tr>
<tr><td >
<input type="checkbox" name="dstn" value="Hobart"
onclick="destintion(this);" />Hobart :- <input type="text" name="num_tick_hob" size="10" /></p></td></tr></td></tr>
<tr><td ><h4><font>Select Your Payment Option:-</font></h4></td></tr>
<tr><td>
<input type="radio" name="pay" onClick="selectpay_meth();" value="Cash"/>Cash</td></tr>
<tr><td><input type="radio" name="pay" onClick="selectpay_meth();" value="Credit Card"/>Credit Card</td></tr>
<tr><td><input type="radio" name="pay" onClick="selectpay_meth();" value="Cheque"/>Cheque</td></tr>
<tr><td><input type="radio" name="pay" onClick="selectpay_meth();" value="EFTPOS"/>EFTPOS</td>
</table>
<p>
<INPUT TYPE="button" NAME="calcsub_tot" VALUE="Sub Total" onclick="calcsub_tot();" />
<INPUT TYPE="text" NAME="calculate" VALUE=""/></p>
<p>
<INPUT TYPE="button" NAME="calcgst" VALUE="GST " width=500 onclick="calcgst();" />
<INPUT TYPE="text" NAME="calculate" VALUE=""/></p>
<p>
<INPUT TYPE="button" NAME="calctot" VALUE="Total " onclick="calctot();" />
<INPUT TYPE="text" NAME="calculate" VALUE=""/></p>
<p>
</form>
<input name="button" type="button" onClick="confirmholiday();return false;" value="Confirm My Booking"/>
</div>
</BODY>
</HTML>
Heres the working file (which is a mess in FF, btw, but not really a concern)