how to add suffix with form name in javascript
hi I have a function in javascript in which I am accessing the hidden value of a form. I want to add a suffix in javascript. I am开发者_C百科 try like this
function add_new_certification(vid)
{
var sr=document.form_vid.hidden.value;
alert(sr);
}
I want to concate vid value with form name. How Can I do that
Use square bracket notation if you want to access a property when you have its name stored in a string.
foo['b' + 'ar']
is the same as
foo.bar
function add_new_certification(vid) {
var fn = 'form_' + vid;
var sr=document[fn].hidden.value;
alert(sr);
}
精彩评论