Hi All!!
Having problems getting data to out textarea quote. I've read heaps of tutorials on variables etc but i can't find any that show how calculate using heaps of variables only 2 or 3.
This is for an assignment and we have done minimal class work on javascript and my text books and online references for my class don't have any instruction on how to do what's required. I've searched the web and changed my code 100 times and the more changes I make it just seems to be getting worse.
What the code is meant to do:
Output quantity.
calculate price if option 1 or 2 is selected.
If card or giftwrapping is selected add that to the price for each item. E.G 20 items + 20 cards.
Is it a once only order or ongoing.
If ongoing is it monthly, six monthly or yearly - Apply discount to total of 5,4,3% respectively.
Is the service for 1,2 or 3 years - and apply a discount of 2% for each year off the order total.
Calculate the number of items that would be ordered for the entire period.
E.G. Quantity = 20. Option = 2. 20x2 = 40. 40 x 12 (monthly) x 2 years.
Total quantity = 960 for total period.
Output total Price after additions and discounts.
Code:
<html>
<title>
Subscriptions
</title>
<style>
body {
background:#000000;
}
</style>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--Changed body tag to head-->
<head>
<script language="JavaScript" type="text/javascript">
function filladdress(f) {
if(f.addsame.checked == true) {
f.daddress.value = f.address.value;
f.dcity.value = f.city.value;
f.dpostcode.value = f.postcode.value;
}
}
</script>
<script language="JavaScript" type="text/javascript">
function calculateTotal()//calculation model to calculate output
{
var quantity
var numberVariable
var card
var Option = 1
var numberYears = "0"
var numberCost = "0"
var wordNo = "0"
var giftwrap
var gst = "0"
var gstFree = "0"
var totalCost = "0"
var servicePeryear = "0"
var numberMonthly
var numberHalfyearly
var numberYearly
}
if (quantity <= 30) {
numberVariable = 10*quantity;
}
else if (option){
numberVariable = 15*quantity + option;
}
else if (quantity> 30 && quantity<=60) {
numberVariable = 8*quantity;
}
else if (option){
numberVariable = 12*quantity + option2;
}
else if (quantity>60) {
numberVariable =8*quantity;
}
else if (option){
numberVariable = 11*quantity + option2;
}
if (card ==Yes){
numberCost = numberVariable + (quantity*2)
}
if (giftwrap == true)
{
giftwrap = numberCost * 1.03;
}
if (totalService >0)
{
numbersYears * 0.95;
servicesperyear = 12;
numberMonthly;
}
else if ()
document.subscriptions.quote.value = ('Business Name:\t\t' + A + '\nAddress:\t\t'
+ B + '\nTown/City:\t' + C + '\nPostcode:\t' + D + '\nDelivery Address:\t' + E +
'\nService Type:\t\t' + G + '\nService Interval:\t' + H + '\nContract Period:\t'
+ I + '\nquantity:\t' + J + '\nOption:\t\t' + K + '\nCard Included:\t' + L +
'\nGift Wrap:\t' + M + '\nTotal Services:\t\t' + servicenumber + '\nCost Per
Service:\t$' + cost + '\nTotal Before GST:\t$' + gstfree + '\nGST:\t\t\t$' + gst
+ '\nGrand Total:\t\t$' + totalcost)
}
</script>
<meta http-equiv="content-type" content="text/html; " />
<script language="JavaScript" /javascript">
$(document).ready(
var winSize = $(window).width();
var margin = winSize % 10;
function setMargin(){
$('#main').css({'margin-left':margin,'margin-right':margin});
}
)
</script>
</head>
<form name=subscriptions>
<body>
<div id="main" align="middle" style="width:1000px; height:50%; text-align:left;
border: #000 solid 1px; margin:auto;">
<div id="inner1" style="width:100%; height:20%; background-color:#E6E6FA;
float:top; border: #000 solid 1px;">
<div id="inner11" align="center"><br/>Quote</div>
</div>
<div id="inner2" style="width:100%; height:200%; background-color:#FFFAF0;
border: #000 solid 1px;">
<div id="inner21" align="left" style="width:70%; background-color:#F0F8FF;
float:left;"></div>
<form action="" id="buffetquote" onsubmit="return false;">
<fieldset><legend>Billing Information</legend>
Business Name:<input name="name"size="30"/>
Address:<input name=address size="30"/>
Town/City:<input name=city size="30"/>
Postcode:<input name=postcode size="4" maxlength="4"/><br/>
</fieldset>
<br>
<fieldset><legend>Contact Details</legend>
Contact Person:<input "
name="name"size="30"/>
Contact Number:<input "
name="phone number"size="30"/><br/>
</fieldset>
<br/>
<fieldset> <legend>Delivery Information</legend>
Tick if same as Billing Address
<input type=checkbox name=addsame onclick=filladdress(this.form)>
Delivery Address:<input name=daddress size="30"/>
Town/City:<input name=dcity size="30"/>
Postcode:<input name=dpostcode size="4" maxlength="4"/><br/>
</fieldset>
<br/>
<div id="onceonly" align="left">ONCE ONLY SERVICE:</div>
Quantity:<input name="quantity"size="3" maxlength="3"/><br/>
<br/>
Option: 1<input type="radio" name="option" value=" 1" onclick="calculateTotal()"
/>
2<input type="radio" name="option" value="2" onclick="calculateTotal()"
/><br/>
<br/>
Card <input type=checkbox name=card value=0 onclick="calculateTotal()"/>
Giftwrap <input type=checkbox name="giftwrap" value=0 />
<br/><br>
Service Type<br>
Once Only <input type=radio name=frequency value=o /> Regular <input type=radio
name=frequency value=r /><br> <br>
<div id=ongoing>
Number of Services:<br/>
Monthly<input type="radio" name="schedule" value="12" onclick="calculateTotal()"
/>
6 Monthly<input type="radio" name="schedule" value="2" onclick="calculateTotal()"
/>
Yearly<input type="radio" name="schedule" value="1" onclick="calculateTotal()"
/><br/>
<br/>
Number of Years:<br/>
1 Year<input type="radio" name="years" value="1"onclick="calculateTotal()" />
2 Years<input type="radio" name="years" value="2" onclick="calculateTotal()" />
3 Years<input type="radio" name="years" value="3" onclick="calculateTotal()" />
<br/>
</div>
<p><input type="button" name="calculate" value="Calculate"
onclick="calcaulateTotal" />
<input name="reset" type="reset" value="Reset" onclick="resetfrom" /></p>
</div>
<div id="inner3" style="width:100%; height:100%; float:bottom; background-
color:#FFFAF0; border: #000 solid 1px;">
<div id="inner23" align="left">Quotation</div>
<textarea name=quote rows=10 cols=100 > </textarea>
</script>
</body>
</html>
Please don't laugh I know it's bad, lol. Any assistance would be much appreciated.