Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用表单2 html js发送数据 名字:_Javascript_Html - Fatal编程技术网

Javascript 使用表单2 html js发送数据 名字:

Javascript 使用表单2 html js发送数据 名字:,javascript,html,Javascript,Html,我不确定我是否理解您的问题,但您可以从JS获取表单信息: <form> First Name: <INPUT type="text" ><br> <input type="radio"><br> <input type="checkbox"><br> <input type="textarea"> </FORM> <FORM action="file.php" method

我不确定我是否理解您的问题,但您可以从JS获取表单信息:

<form>
First Name:
<INPUT type="text" ><br>

<input type="radio"><br>

<input type="checkbox"><br>

<input type="textarea">

</FORM>

<FORM action="file.php" method="post" name=form1>

<INPUT type="submit" value="Submit"> 

</FORM>

提交一个表单时使用两个表单标签的方式:

试试这个:

HTML:

function myFunc() {
  var name = document.getElementById('name');
  alert(name.value);
  return false; // Return false to cancel the submit
}
<form id="myForm" action="action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br><br>
  <input type="button" onclick="myFunction()" value="Submit form">
</form>

名字:
姓氏:

JAVASCRIPT:

function myFunc() {
  var name = document.getElementById('name');
  alert(name.value);
  return false; // Return false to cancel the submit
}
<form id="myForm" action="action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br><br>
  <input type="button" onclick="myFunction()" value="Submit form">
</form>

函数myFunction(){
document.getElementById(“myForm”).submit();
}