[Javascript] form query

Chris Tifer christ at saeweb.com
Wed Oct 1 08:06:48 CDT 2003


The obvious problem on product.length is that product was not defined properly:

var product = new Array [33]

Should instead by:

var product = new Array(33)

Although to be honest with you, I wouldn't hard-code how many elements are in this array. Define the variable as an array then just add elements as you see fit. The length property will be set on its own.

Chris Tifer
http://micclub.net

  ----- Original Message ----- 
  From: Frank Davie 
  To: javascript at LaTech.edu 
  Sent: Tuesday, September 30, 2003 10:43 PM
  Subject: [Javascript] form query


  Dear Javascript List,
  I am teaching myself javascripting and have decided to tackle this form menu, I have to display the totals, days,and email confirm.
  The only thing is I cannot get the script far enough to calculate the total, I get an error message saying product.length is null or not an object.
  Could you possibly give me a solution to calculate and display the subtotal and total so I can move on to the days and email calcs.

  thanks

  p.s 

  I have enclosed the form 




  function calc(f){  
   var qty = new Array();
   var subtotal;
   
   var total = 0;
   var i = 0;
   var num= 1;

   while ( num !=0 && i < product.length) {
    qty[i] = num;
                 subtotal = subtotal + qty[i] * prices[i]
    
   
   
                                                 }

                          }


------------------------------------------------------------------------------


  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20031001/00924585/attachment.htm>


More information about the Javascript mailing list