admin管理员组文章数量:1316523
I have a two variables. One containing the value of the `name` attribute of an input element, and another containing the value of the name attribute of its form element.
Using JavaScript how do I reference that input element just like below, except for replacing the inputname with the value of the variable that contains the name attribute of the input element, and the formname with the value of the variable that contains the name attribute of the form element?
document.formname.inputname
I don't mean to sound plicated, and I am looking forward to a reply,
-An inquisitive Web Developer
I have a two variables. One containing the value of the `name` attribute of an input element, and another containing the value of the name attribute of its form element.
Using JavaScript how do I reference that input element just like below, except for replacing the inputname with the value of the variable that contains the name attribute of the input element, and the formname with the value of the variable that contains the name attribute of the form element?
document.formname.inputname
I don't mean to sound plicated, and I am looking forward to a reply,
-An inquisitive Web Developer
Share Improve this question asked Apr 14, 2011 at 15:31 Web_DesignerWeb_Designer 74.7k93 gold badges209 silver badges266 bronze badges1 Answer
Reset to default 5Hmm, I think you could just use this:
document.forms['nameOfForm']['nameOfFormElement'];
And to get the value of the elements, just append .value
to the end:
document.forms['nameOfForm']['nameOfFormElement'].value;
本文标签: htmljavascriptuse variables of input and form names to reference input elementStack Overflow
版权声明:本文标题:html - javascript - use variables of input and form names to reference input element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741997898a2410418.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论