trying to implement a javascript call in my php code
Posted: Wed Mar 28, 2007 1:48 pm
feyd | Please use
in my form I have this[/syntax]
The "onFocus='total()' isn't changing my total price. I know I'm missing something, could someone please point me in the right direction.
thank you
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have an order form I am trying to get to auto calculate the total sales price based on quantity. I am trying to use a javascript function to calculate the total priced based on the quantity entered.
I have this in [syntax="html"]
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Order Page - Bloodlines of the Legends</title>
<script>
function total()
{
var qty= document.form1.quantity.value;
var price=document.form1.price.value;
var total=qty*pxeach;
document.form1.totalprice.value=total;
}
</script>
</head>
Code: Select all
echo "<p align='center'>Quantity <input type='text' name='quantity' size='20' value=$quantity_ordered></p>";
/* I seed $quantity_ordered with a default value of 1 */
echo "<p align='center'> Price Each<input type='text' name='pxeach' size='20' value=$price_each></p>";
/* I pass the price each with the form that calls this form */
echo "<p align='center'>Total <input type='text' name='totalprice' size='20' onFocus='total()' value=$total_price ></p>";thank you
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]