[thelist] Javascript Eval Help....

Anthony Baratta Anthony at Baratta.com
Tue Jul 23 19:02:01 CDT 2002


I can't see my error....

I'm gettting an error with this line:

    eval('document.FormOOS.prod' + x + 'Subtotal.value') =
         parseInt(eval('document.FormOOS.prod' + x + 'Qty.value')) *
         parseFloat(eval('document.FormOOS.unitPrice' + x + '.value'));

The error is:

    Error: invalid assignment left-hand side

document.FormOOS.prod' + x + 'Subtotal' exists in the form, but I can't
seem to assign a value to it when I use the Eval function.

Here's the function:
(don't be confused with the little ASP code in there ;-)

function reCalcOrderForm() {

  document.FormOOS.EDUSubtotal.value = 0

  for (x=1;x<=<%=i%>;x++) {
   if (eval('document.FormOOS.prod' + x + 'Qty.value') != "") {
    if (isNaN(eval('document.FormOOS.prod' + x + 'Qty.value'))){
      eval('document.FormOOS.prod' + x + 'Qty.value') = "0";
    }
    eval('document.FormOOS.prod' + x + 'Subtotal.value') =
         parseInt(eval('document.FormOOS.prod' + x + 'Qty.value')) *
         parseFloat(eval('document.FormOOS.unitPrice' + x + '.value'));
    document.FormOOS.EDUSubtotal.value =
         parseFloat(document.FormOOS.EDUSubtotal.value) +
         parseFloat(eval('document.FormOOS.prod' + x + 'Subtotal.value'));
   }
  }
}

Any ideas??
---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."




More information about the thelist mailing list