Call document.form.action when form is a variable

B

brian.gaber

When the form name is held in a variable how do I call
document.form.action?

For example:

var form_name = "status_" + idx;
theForm.action = document.form_name.action;
 
B

brian.gaber

Thanks. Another related question:

function status_OnChange(theForm) {

var actn = theForm.action;
alert("Action name:" + actn); // THIS SHOWS THE ACTION VALUE OF THE
SCRIPT e.g. Action name: script.pl?key1=value1&key2=value2

var addCmnt_form = "addCmnt_" + nameArr[1];
var nu_actn = document.forms[addCmnt_form].action;
alert("Action name:" + nu_actn); // THIS SHOWS Action name: [Object]

Why the difference?

Thanks
For example:
var form_name = "status_" + idx;
theForm.action = document.form_name.action;

   document.forms[form_name].action
Read onhttp://jibbering.com/faq/#FAQ4_39.
 
M

Martin Honnen

var addCmnt_form = "addCmnt_" + nameArr[1];
var nu_actn = document.forms[addCmnt_form].action;
alert("Action name:" + nu_actn); // THIS SHOWS Action name: [Object]

Well you will have to show the relevant HTML and the value of all
variables but the result you see is likely caused by having a form
control with name 'action' e.g.
<input type="text" name="action">
in the form you are accessing.
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top