[thelist] JavaScript: cannot assign to a function result

.jeff jeff at members.evolt.org
Wed Mar 5 18:40:00 CST 2003


> From: Joel Canfield
> So, if I can't assign to a function result, what *do*
> I do? Seems like this should be obvious, but it ain't.
> This function just grabs the value of a radio button
> group using the GetRadioValue function. So, how do I
> get the result of GetRadioValue into the current
> iteration of glcodesub?
> function SaveRadioValueGLCodeSub(RadioGroup, j)
> {
> 	strGLCodeSub = "window.document.theForm.glcodesub" + j + ".value"
> 	eval(strGLCodeSub = GetRadioValue(RadioGroup));
> }

your question and the code snippet leave me wondering what exactly your
question is.  however, there are some things i'd like to address about your
code snippet that may end up helping:

array notation, array notation, array notation.

instead of:

strGLCodeSub = "window.document.theForm.glcodesub" + j + ".value"


strGLCodeSub = window.document.theForm.elements['glcodesub' + j].value;

now, i'm guessing that the value of the form field should then be used to
create a variable to hold the value of a particular checked radio button.
rather than using eval(), simply reference strGLCodeSub as a dynamic
property of the self object:

self[strGLCodeSub] = GetRadioValue(RadioGroup);

there, no eval() needed.

see if that doesn't help ya.



NOTICE:  members.evolt.org web and email address are changing!
| OLD:                            | NEW:                            |
| jeff at members.evolt.org          | evolt at jeffhowden.com            |
| http://members.evolt.org/jeff/  | http://evolt.jeffhowden.com/    |

More information about the thelist mailing list