codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  script works on a plain form but not within a table...  Berolina at 17:38 on Thursday, June 01, 2006
 

I have a very small javascript function, where I want to multiply a "quantity" with the item's price and add a postage charge if quantity is less than 3 items, and finally display a total amount. Quantity is the only user input. When I placed this code inside a table on my webpage I could not get it to display the total amount; it does work if used on a webpage without tables... WHY??!

Notes: I'm using FrontPage for the webdesign; is that what's causing the problem??

This is the script:

<SCRIPT language = JavaScript>
function calculate()
{
var quant = document.orderfrm.txtqty.value
var quantity = Number(quant)
var postage = 0.50
var price = 3.99
if (quantity < 3)
{
var finalprice = (price + postage) * quantity
}
else
{
var finalprice = quantity * price
}
document.orderfrm.txtamount.value = finalprice
}
</SCRIPT>



and this is where it's called (I left out formatting code for clarity):

<input type="text" name="txtqty">Total Order Price:
<input type="button" value="update" name="b1" onClick = calculate()>
<input type="text" name="txtamount" size="5" value="">











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  jslider - paint track
•  Re: convert minutes into hours and minutes
•  File handle problem
•  Link Capture, help needed
•  Re: java app auto web update..
•  IE Only comeback
•  ` Error Code 64: Host not available ` - Error when accessing ASP Appln
•  Re: dynamic crystal report generation
•  Launch an app remotely through a website


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007