[Javascript] Variable in Object

Peter-Paul Koch pp.koch at gmail.com
Fri Jan 6 07:50:43 CST 2006


> var icd9 = '123.12';
>
> This works.
>
> window.opener.document.invoice.diagnosis_0.value = icd9;
>
> This doesn't:
>
> var element = 'diagnosis_0';
>
> window.opener.document.invoice.element.value = icd9;
>
> I've tried a constructor and an eval and I can't get the variable into the
> object. How do I insert a variable name into the object?

window.opener.document.invoice[element].value = icd9;

--
-------------------------------------------------------------------
ppk, freelance web developer
http://www.quirksmode.org/
------------------------------------------------------------------



More information about the Javascript mailing list