Home > Web Front-end > JS Tutorial > Focus on answering several submission methods of js

Focus on answering several submission methods of js

亚连
Release: 2018-05-17 11:13:39
Original
1663 people have browsed it

The following are several ways to submit js

We often need to submit forms or hyperlinks through js

1.js submit form (.submit() method submits the form)

function doSearch(){
var action ="<%=path%>/User_queryAllUser";
document.all.form.action = action;
document.all.form.submit();
}
Copy after login

2.js submits the form (.submit() method submits the form)

<script type="text/javascript">
function addSubmit()
{
var targetForm = document.forms[ "form1" ];
targetForm.action = "logo.do?method=downAdd";
targetForm.submit();
}
</script>
<form name="form1" method="post" action="logo.do" enctype="multipart/form-data">
Copy after login

3.js replaces the hyperlink (window.location.href)

<input type="button" id="modify" value="修改工号" onclick="modifyEmp(${ myList.employeeId })">
//js不能起名为modify,为敏感关键字
function modifyEmp( employeeId ){
//employeeId 作为js的参数传递进来
window.location.href = &#39;<%=path%>/User_openUserUpdate?employeeId=&#39;+employeeId;
}
Copy after login

The above are several ways to submit js that I have compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Explain in detail the Windows object course in JS

Introduce several types of events in js in detail The way to handle the program

Focus on analyzing and answering the js and el expression operation list

The above is the detailed content of Focus on answering several submission methods of js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template