Page 1 of 1

[SOLVED] Alernate soln for getElementByName

Posted: Thu Feb 03, 2005 4:43 am
by anjanesh

Code: Select all

<FORM NAME=frm1 METHOD=POST>
...somewhere here onClick="clickme(1)"
</FORM>

<FORM NAME=frm2 METHOD=POST>
...somewhere here onClick="clickme(2)"
</FORM>

<FORM NAME=frm3 METHOD=POST>
...somewhere here onClick="clickme(3)"
</FORM>
Is there any way I can have this in a JS code ?

Code: Select all

function clickme(n)
 &#123;
 document.(frm+n).whatever.value="something";
 // Should produce document.frm1.whatever.value="something";
 // Should produce document.frm2.whatever.value="something";
 // Should produce document.frm3.whatever.value="something";
 &#125;
Since getElementByName is unavilable how else can I have it done ?
Thanks

Posted: Thu Feb 03, 2005 9:56 am
by feyd

Code: Select all

document.forms&#1111;'frm1']....

Posted: Thu Feb 03, 2005 11:44 am
by anjanesh
Thank you Feyd.