[UPHPU] submitting a form with javascript, dynamic form name

Alvaro Carrasco simplepic at gmail.com
Thu Jul 9 20:53:02 MDT 2009


Hi,
See below:

Wade Preston Shearer wrote:
> On 8 Jul 2009, at 18:56, Wade Preston Shearer wrote:
>
>> I am submitting a form with javascript like this…
>>
>> document.formname.submit();
>>
>>
>> I need the name of the form to be a variable though. Is that 
>> possible? Meaning, that "formname" should be a variable instead of 
>> the actual name of the form.
>
> And of course, I find the answer right after reaching out for help.
>
> eval('document.' + name + '.submit()');
>

There's no need to use eval (which should be avoided when possible for
various reasons). You can do this:

document.forms[name].submit();

Alvaro






More information about the UPHPU mailing list