html form passes value instance to jiavascript

高洛峰
Release: 2017-03-28 11:24:10
Original
1511 people have browsed it

This article mainly introduces in detail the example of transferring value from html form to jiavascript, which has certain reference value. Interested friends can refer to

The code of the experiment is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>你好</title>
</head>
<script language="javascript">
function sub(a,b){
alert(a.value);
        alert(b.value);
}
</script>
   
<body>
<form action="sub" method="post"  name="myForm">
  <p>First name: <input type="text" id=test1 name="fname" /></p>
  <input type="button" value="Submit" onclick="sub(this,document.myForm.fname)" />
</form>
</body>
</html>
Copy after login

Summary:

onclick="sub(this,document.myForm.fname)" this is the id of the return button

The above is the detailed content of html form passes value instance to jiavascript. 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