Home > Article > Web Front-end > html form passes value instance to jiavascript
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>
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!