Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding two total prices together to display as absolute total

Status
Not open for further replies.

data1

Programmer
Aug 19, 2003
25
0
0
NZ
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot;>
function calculate(){
var f = document.form1;
var first = f.t1.value;
var second = f.t2.value;
var third = f.t3.value;
var fourth = parseFloat(first) + parseFloat(second) + parseFloat(third);
f.t4.value = fourth;
f.totalPrice.value = (fourth * 18.95).toFixed(2);
}

function calculate1(){
var f = document.form;
var first = f.t1a.value;
var second = f.t2a.value;
var third = f.t3a.value;
var fourth = parseFloat(first) + parseFloat(second) + parseFloat(third);
f.t4a.value = fourth;
f.totalPrice1.value = (fourth * 18.95).toFixed(2);
}


function totalprice(){
var a = document.form2
var totala = f.totalPrice.value;
var totalb = f.totalPrice.value;
var i = parseInt(totala) + parseInt(totalb)
f.completeTotal.value = i;



}


</script>
</head>

<body>
<form name=&quot;form1&quot;><input type=&quot;text&quot; name=&quot;t1&quot; value=&quot;.0&quot;><input type=&quot;text&quot; name=&quot;t2&quot; value=&quot;0&quot;><input type=&quot;text&quot; name=&quot;t3&quot; value=&quot;0&quot;><input type=&quot;text&quot; name=&quot;t4&quot;>



<INPUT type=&quot;text&quot; name=&quot;totalPrice&quot; onFocus=&quot;document.form1.totalPrice.blur()&quot; readonly=&quot;true&quot;>



<INPUT type=&quot;button&quot; value=&quot;calculate&quot; onClick=&quot;return calculate()&quot;>
</form>
<hr width=&quot;720&quot;>
<form name=&quot;form&quot;>

<br>

<input type=&quot;text&quot; name=&quot;t1a&quot; value=&quot;.0&quot;><input type=&quot;text&quot; name=&quot;t2a&quot; value=&quot;0&quot;><input type=&quot;text&quot; name=&quot;t3a&quot; value=&quot;0&quot;><input type=&quot;text&quot; name=&quot;t4a&quot;>



<INPUT type=&quot;text&quot; name=&quot;totalPrice1&quot; onFocus=&quot;document.form1.totalPrice1.blur()&quot; readonly=&quot;true&quot;>



<INPUT type=&quot;button&quot; value=&quot;calculate&quot; onClick=&quot;return calculate1()&quot;>

</form>
<hr>
<br>
<form name=&quot;form2&quot;>


<INPUT type=&quot;text&quot; name=&quot;completeTotal&quot; onFocus=&quot;document.form1.completeTotal.blur()&quot; readonly=&quot;true&quot;>
<INPUT type=&quot;button&quot; value=&quot;totalprice&quot; onClick=&quot;return totalprice()&quot;>

</form>

</body>
</html>
 
so whats the problem (sorry i couldnt test ur code)...

Known is handfull, Unknown is worldfull
 
You need to go back thru your code and clean it up. You have variables that aren't defined, forms that don't exist, and I stopped after that.

Clean it up and you may find that it works.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top