Re: Help with "cannot assign string" error
- From: VK <schools_ring@xxxxxxxxx>
- Date: 29 Apr 2007 08:44:05 -0700
On Apr 29, 7:07 am, Don Lancaster <d...@xxxxxxxxxx> wrote:
I need to progrmatically do this inside a loop
this.fh03.value = fixFloat (Harms[1], numPoints) ;
with the numbers changing per an index.
If I try
curHvals = "03" ; // (derived from index to provide leading zero)
( "this.fh" +curHvals + ".value" ) = fixFloat(Harms[ii],numPoints)
I get a [ Cannot assign string to 'string "this.fh03.value" ' error. ]
The right side of the equation works just fine elsewhere.
As does this.fh03.value elsewhere.
eval (...) does not work as it looks up the previous fh03 value rather
than replacing it with a new one.
What is the correct way to programatically loop calculated values with
fancy names?
If I understood your problem properly then I would form the question
in some other way:
- How to access form controls using run-time generated control names
(so they cannot be hard coded as literals in my program).
- Use squared brackets notation with expression in it:
refFormElement.elements["fh"+curHvals].value =
fixFloat(Harms[ii],numPoints);
.
- References:
- Help with "cannot assign string" error
- From: Don Lancaster
- Help with "cannot assign string" error
- Prev by Date: Re: Help with "cannot assign string" error
- Next by Date: Re: javascript dns look up
- Previous by thread: Re: Help with "cannot assign string" error
- Next by thread: Blocking input into a text area
- Index(es):