![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.javascript archiveRe: How to use a variable as a part of an object
From: RobG <rgqld@iinet.net.au>
Date: Wed Nov 30 2005 - 22:00:29 CET
Stefan Mueller wrote:
Yes:
document.MyForm.elements[MyVariable].value = "Test";
or
document.MyForm[MyVariable].value = "Test";
I prefer the former as it is clear that MyVariable refers to the form's
They are equivalent to:
document.MyForm.elements["MyInput1"].value = "Test";
When you use dot notation, the script engine looks for a property with
It's covered in more detail in the FAQ:
<URL: http://www.jibbering.com/faq/faq_notes/square_brackets.html >
-- RobReceived on Sat Dec 3 04:34:00 2005 |