D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Some help with javascript & firefox

 

Kevin Lucas wrote:
> I have edited the loop but still get only the literal string "sum += 
> parseInt( document.splitfm.vat_low3.value " as an input to the box  
> low_vattot
> what do I need to convert this to the .value?
Ahh.. penny has dropped... I think.

Steven may correct me if I'm wrong on this but IIRC Javascript evaluates 
symbols thus:

== (double =) means 'this is the content of'
=  means 'this is the result of'

Not sure if that makes linguistic sense so here's an example:

a = 2 + 4  result - a = 6

a== 2+4  result - a is a string '2+4'

In other words I think you may have a == where you want a =, or vice versa.

Also, it may be the single quotes around the expression telling the 
script to enclose the lot in a string;

vat_low = 'sum += parseInt( document.splitfm.vat_low' + i + '.value )';

Try:

vat_low = sum += parseInt( document.splitfm.vat_low' + i + '.value );

I notice as well that vat_low isn't given an initial value, so the 
script may assume it's a string and not be calculating the value as a 
mathematical value, but concatenating it as a string.

Kind regards,

Julian

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html