Connecting Tech Pros Worldwide Forums | Help | Site Map

Calculate total Function - please help me debug

Newbie
 
Join Date: Feb 2008
Posts: 2
#1: Feb 25 '08
This script calculates the total "listing_fee" based on the price that the user inputs into the "price" field. It works in Firefox but IE says "OBJECT NOT FOUND" please help me debug this, It's sooooo close! :)

Thanks in advance for any help or guidance!!


[HTML]function calc() {
tprice = document.sellticket.price.value;
newprice = .05 * tprice;
var result1 = newprice * Math.pow(10, 2)
var result2 = Math.round(result1)
var result3 = result2 / Math.pow(10, 2)
newprice = "$" + newprice;
document.sellticket.listing_fee.value=newprice;
document.sellticket.listing_fee2.value=newprice;
}

<form name="sellticket" action="sell_ticket.php" method="post">
Sale Price:
<input type="text" name="price" size="5" onInput="calc()">

Listing Fee:
<input type="text" name="listing_fee" onFocus="this.form.elements[0].focus()">

<input type="submit" value="Submit">
</form>[/HTML]

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Feb 26 '08

re: Calculate total Function - please help me debug


There's no listing_fee2 element.

You may also want to use onchange instead of onInput.
Newbie
 
Join Date: Feb 2008
Posts: 2
#3: Feb 26 '08

re: Calculate total Function - please help me debug


thank you very much!!!!

it all works now.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Feb 27 '08

re: Calculate total Function - please help me debug


No problem. Post again should you have more questions.
Reply