开发者

How do I get the name of a form in Javascript?

How do I get the name of a form in Javascript?

I have tried stuff like:

document.forms[0].name
document.forms[0].id //I 开发者_如何转开发have both name and id set


Strange. Should both work.

Are you 100% sure you have no other form(s) in the document? Does

document.getElementById('form_id').name

work? (form_id being the ID you assigned).


document.forms[0].name works for me in both IE7 and FF3.5... I guess there must be some other problem.

(Are you trying to access the name from a <script> element at the top of the HTML, before the form has appeared?)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜