Guest The Ribbon Printer Posted December 4, 2006 Share Posted December 4, 2006 Help! - I'm trying to write some code for our company website.Basically it is a calculator that shows how much it will cost to print a metre of ribbon - the variables are: Colour of ink (radio boxes assigned a value in pence)length and cost of the roll of ribbon they have and the width of the ribbon.The calculation is simple - cost of roll of ribbon / length of roll plus the cost of the ink * 1 if the ribbon is wider than 50mm and times 0.5 if narrower than 50mmMy code is: <script type="text/javascript"><!--var rw = document.calc.width.valueif (rw <50) {document.calc.rw1 = 0.5}else{document.calc.rw1 = 1} function showpay() { if ((document.calc.length.value == null || document.calc.length.value.length == 0) || (document.calc.cost.value == null || document.calc.cost.value.length == 0) || (document.calc.width.value == null || document.calc.width.value.length == 0)) { document.calc.cpm.value = "Incomplete data"; } else { var to = document.calc.theone; var rl = document.calc.length.value; var rc = document.calc.cost.value; var rw1 = document.calc.rw1.value; document.calc.cpm.value = rc / rl * (to * rw1); }// payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months))}// --></script>Click the Calculate button. Clicking the Reset button will clear enteredvalues.<p><center><form name=calc method=POST>Metallic Gold/Silver: <input type="radio" name="colour" onClick="theone=0.20"><br>Silver/White: <input type="radio" name="colour" onClick="theone=0.08"><br>Red/Green/Blue: <input type="radio" name="colour" onClick="theone=0.07"><br>Black: <input type="radio" name="colour" onClick="theone=0.06"><br><table width=60% border=0><tr><th bgcolor="#aaaaaa" width=50%><font color=blue>Description</font></th><th bgcolor="#aaaaaa" width=50%><font color=blue>Data Entry</font></th></tr><tr><td bgcolor="#eeeee">Ribbon Length in Metres</td><td bgcolor="#aaeeaa" align=right><inputtype=text name=lengthsize=10></td></tr><tr><td bgcolor="#eeeee">Ribbon Cost in £s</td><td bgcolor="#aaeeaa"align=right><input type=textname=cost size=10></td></tr><tr><td bgcolor="#eeeee">Ribbon Width in mm</td><td bgcolor="#aaeeaa" align=right><inputtype=text name=widthsize=10></td></tr><tr><td bgcolor="#eeeee">Cost Per Metre</td><td bgcolor="#eeaaaa"align=right><em>Calculated</em> <inputtype=text name=cpm size=10></td></tr><tr><td bgcolor="#aaeeaa"align=center><input type=button onClick='showpay()'value=Calculate></td><td bgcolor="#eeeeaa" align=center><input type=resetvalue=Reset></td></tr></table></form><font size=1>Enter only numeric values (no commas), using decimal pointswhere needed.<br>Non-numeric values will cause errors.</font></center> Can anyone help? Link to comment Share on other sites More sharing options...
MrAdam Posted December 4, 2006 Share Posted December 4, 2006 perhaps .. var rw1 = document.calc.rw1.value; should it be: var rw1 = document.calc.width.value; ?? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now