C
Confused
Hi,
My background is more in C and PHP than javascript, but occasionally I
have to write small javascript functions. I recently needed to write
one where the parameter was the name of a form. The only way I could
find to assign the value of this form to a local variable was like
this:
function myFunction(formname)
{
var string = 'var f = document.' + formname;
eval(string);
This looks like a bit of a hack to me. Is there a better way to do
this?
Thanks.
My background is more in C and PHP than javascript, but occasionally I
have to write small javascript functions. I recently needed to write
one where the parameter was the name of a form. The only way I could
find to assign the value of this form to a local variable was like
this:
function myFunction(formname)
{
var string = 'var f = document.' + formname;
eval(string);
This looks like a bit of a hack to me. Is there a better way to do
this?
Thanks.