[LBo] OT: Javascript question
Jisao
dimark at securenet.net
Sat Sep 9 03:10:58 CEST 2006
I need to alter a javascript, and I don't know how to do javascript.
Right now, I have a form that calculate orders for books. It is a radio
button to be clicked. I wish to replace it with a quantity instead, so
that if somebody wants 2 books, it calculates twice the amount for the
books.
Here is the present scheme (I quote only part of the form) - the radio
button I wish to replace:
<input language="JavaScript" type="checkbox" onClick="Total()"
name="book07" value="Mary Poppins, paperback">
I want something which would be a number. I found this line of script
from another source:
<label for="textfield">Save:
<input id="textfield" type="text" size="5" maxlength="4"
value="0" />
</label>
Now I wonder how to write these for the script below. (Of course the
script would need to be slightly altered too). Especially the line:
document.ecom.frtotallivres.value = round(tot);
which would become something like: document.ecom.frtotallivres.value
= round(qty * tot).
However, I do not know how to define the qty parameter in the script,
which would have been inputted in the purchase form.
Any suggestions?
Please let me know if my question is not clear.
Tx
Jisao
The script per say reads:
(frfraismenu is shipping,
<script language="JavaScript" type="text/javascript">
<!--
// function to calculate the total cost of a book order
function round(num) {
return Math.round(num * 100) / 100;
}
function Total() {
var tot = 0.00;
var tps = 0.06;
var frfraismanu = 3.50;
if (document.ecom.book01.checked)
tot += (35.00);
if (document.ecom.book02.checked)
tot += (9.50);
if (document.ecom.book03.checked)
tot += (12.75);
if (document.ecom.book04.checked)
tot += (12.75);
if (document.ecom.book05.checked)
tot += (23.00);
if (document.ecom.book06.checked)
tot += (30.00);
if (document.ecom.book07.checked)
tot += (30.00);
document.ecom.frtotallivres.value = round(tot);
document.ecom.frtotaltaxes.value = round((tot * tps));
document.ecom.frtotalfrais.value = round((tot + (tot * tps) +
frfraismanu));
}
// -->
</script>
More information about the QnA
mailing list