如何通过javascript提交表单form
来源:互联网 发布:面试linux运维故障处理 编辑:程序博客网 时间:2024/06/05 14:25
--How to Submit aForm Using JavaScript
Generally, aform is submitted when the user presses a submit button. However,sometimes, you may need to submit the form programmatically usingJavaScript.
JavaScript provides the form object that contains the submit()method. Use the ‘id’ of the form to get the form object.
For example, if the name of your form is ‘myform’, the JavaScriptcode for the submit call is:
document.forms[
"myform"
].submit();
But, how to identify a form? Give an id attribute in the formtag
<
form
id
=
'myform'
action
=
'formmail.pl'
>
Here is the code to submit a form when a hyperlink is clicked:
<
form
name
=
"myform"
action
=
"handle-data.php"
>
Search: <
input
type
=
'text'
name
=
'query'
/>
<
a
href
=
"javascript:submitform()"
>Search</
a
>
</
form
>
<
script
type
=
"text/javascript"
>
function submitform()
{
document.myform.submit();
}
</
script
>
JavaScript Form Submit Example 1
<html><head>url</head>
<scriptsrc="http://code.jquery.com/jquery-latest.min.js"></script>
<body>
<formname="testForm" id="testForm"mothod="GET">
<inputtype="text" name="test1" id="order"value="order">
<inputtype="text" name="test2"value="get2">
<inputtype="submit" name="Submit" value="yes">
<ahref="javascript:submitform();">submit</a>
</form>
<scripttype="text/javascript">
functionsubmitform()
{
//document.forms['testForm'].submit(); //this willbe ok,here is name="testForm"
$('testForm').submit(); //hereis id="testForm"
}
function$(xxx)
{
returndocument.getElementByIdx_x_x_x(xxx);
}
</script>
</body>
</html>
- 如何通过javascript提交表单form
- 如何通过javascript提交表单form
- 如何通过jquery禁止form表单提交
- javascript提交form表单
- JavaScript提交form表单
- Javascript提交form表单
- 通过ajax提交form表单
- form表单提交如何验证?
- Jquery通过Ajax方式提交Form表单
- javaWeb通过iframe异步提交form表单
- document.form.action,表单分向提交,javascript提交表单
- document.form.action,表单分向提交,javascript提交表单
- document.form.action,表单分向提交,javascript提交表单
- JavaScript 或者 jQuery 拼接form表单提交
- js提交form表单(Javascript)
- 写在js文件里的变量如何通过FORM表单提交到action
- 如何通过submit提交form表单获取后台传来的返回值
- 如何解决Form表单的重复提交
- 黑马程序员 Java基础1——Java控制语句
- [转] Java代码质量检测评估工具-PMD
- Ubuntu下安装配置 sun-JDK 7
- Lex&Yacc词法语法分析Yacc(三)
- linux下导入、导出mysql数据库命令
- 如何通过javascript提交表单form
- $(document).ready说明
- 如何通过jQuery实现网格中的行的颜…
- linux shell常用快捷键
- 开机自动拨号 批处理实现拨号连接…
- Lex&Yacc词法语法分析二者结合
- 从linux提取文件内容进行分页,另…
- 正则表达式速查手册(口诀)
- Jquery实现的悬浮按钮,浮现图片