當前位置:
首頁 >
前端技术
> 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前端页面刷