开发者

how to add suffix with form name in javascript

开发者 https://www.devze.com 2023-03-11 00:53 出处:网络
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

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);  
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消