onkeypress
hi, i'm doing a shopping cart where by when user add a product in cart, it will show the qty, item name, and price.
i want to use javascript to do it in a way tat when i change the qty, the price will change also.
for eg, i type 2 in the text field of the qty, then my price will change to original price * 3.
i keep getting error with the javacript below. hope can get help here.
this is the javascript:
<script language="JavaScript">
<!--
function changevalue()
{
orivalue = document.form.our_price.value;
qtyvalue = document.form.qty.value;
newvalue = orivalue * qtyvalue;
document.form.amount.value = newvalue;
//-->
}
</script>
and my text fields are like below..(part of my codes)
<?php
echo \"<form method=post action=user_cart.php name=form>\";
echo \"<input type=hidden name=our_price value=$our_price>\n\";
echo \"<tr><td width=5% align=center><input type=text name=qty value=\\"$qty\\" size=2 class=ft1 onKeyPress=\\"changevalue()\\"></td>\";
echo \"<td width=15% align=center><input type=text name=amount value=\\"$amount\\" class=ft1></td>\";
?>
pls help me...thanks.
ROB posted this at 16:43 — 9th August 2002.
They have: 447 posts
Joined: Oct 1999
what does the javascript error say?
Abhishek Reddy posted this at 07:48 — 10th August 2002.
He has: 3,348 posts
Joined: Jul 2001
Yes, that would help.
Could you also show us the code as it is the output, not the PHP?
Make that the full code from to .
For now, I'm guessing that "form" is an illegal name for a form.
[edit]
Try this:
document.forms.form...
Still, I think you should rename your form to something else.
[/edit]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.