当前位置:
首页 >
前端技术
> javascript
>内容正文
javascript
javascript获取表单值的7种方式
生活随笔
收集整理的这篇文章主要介绍了
javascript获取表单值的7种方式
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
见代码:
<!doctype html> <html lang="en"> <head><meta charset="UTF-8"><title>表单对象--获取表单值的7种方式</title> </head> <body><form action="" name="myform"><input type="text" name="user" value="admin"></form><script>document.write(document.myform.user.value+"1<br/>");document.write(document['myform'].user.value+"2<br/>");document.write(document.forms.myform.user.value+"3<br/>");document.write(document.forms[0].user.value+"5<br/>");document.write(document.forms['myform'].user.value+"4<br/>");document.write(document.forms.item(0).user.value+"6<br/>");document.write(document.forms.item('myform').user.value+"7<br/>");//FF可能不支持</script> </body> </html>
推荐使用
document.write(document.myform.user.value);总结
以上是生活随笔为你收集整理的javascript获取表单值的7种方式的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: centos6.4 搭建JDK环境
- 下一篇: html-javascript前端页面刷