nikko50
01-25-2009, 06:27 PM
If "key" holds the field name how do I insert key into "document.theForm.key.value"? Is what I did below correct?
document.theForm.+key+.value = value;
document.theForm.+key+.value = value;
|
||||
strings?nikko50 01-25-2009, 06:27 PM If "key" holds the field name how do I insert key into "document.theForm.key.value"? Is what I did below correct? document.theForm.+key+.value = value; Philip M 01-25-2009, 06:38 PM Use document.getElementById(key).value instead. Example:- <input type = "text" name = "txt1" id = "txt1" onblur = "chk()"> <script type = "text/javascript"> function chk() { var key = "txt1" var x = document.getElementById(key).value; } </script> “Expert: a man who makes three correct guesses consecutively.” Dr. Laurence J. Peter (American "hierarchiologist", Educator and Writer, 1919-1990) nikko50 01-25-2009, 06:41 PM So I can't reference by name? Tracy nikko50 01-25-2009, 06:56 PM Thanks works great Philip! Tracy rnd me 01-25-2009, 11:59 PM So I can't reference by name? Tracy there is a document.getElementsByName() note that it returns a collection, not just a single tag like getById, so document.getElementsByName("txt1")[0] is probably how you would want to use it. |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum