Using a Form value in Javascript

A

Andy Reed

In my form I have a form value named v6.
I can refer to this value in a javascript as
mainform.v6.value
I can send out an alert {alert(mainform.v6.value);}

Fine.

Is there a way of referring to this value using a
javascript variable as below :-

var xx = 6;
var yy = "mainform.v" + xx + ".value";
{alert(yy);}

This doesn't work but you can see what I want to do.
 
M

MD WebsUnlimited.com

Hi Andy,

Use the eval function.

yy = eval('mainform.v' + xx + '.value');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top