[英]form not submitting data to php
我创建了一个表单,onsubmit 在另一个文件( results.php
)中运行 function (文件已使用 jQuery 加载)。 但是,我可以访问另一个文件( results.php
)上的表单输入。
我创建了一个测试来查看是否设置了数组,但实际上没有。 有什么办法可以在表单上设置数组吗? 如果没有,我如何访问另一个 php 文件中的表单输入?
请注意,我不能使用action="example.php"
,因为这会加载一个新页面,我试图避免这种情况(使用 AJAX 和 jQuery)。
这是表格:
<form onsubmit="loadCatering();return false;">
<table>
<tr>
<td><label for="venueName">Venue Name:</label></td>
<td>
<select id="venueName" name="venueName"required>
<option value = "1">Central Plaza</option>
<option value = "2">Pacific Towers</option>
</select>
</td>
</tr>
<tr>
<td><label for="submit">Check Catering Grades:</label></td>
<td><input type="submit" /></td>
</tr>
</table>
</form>
</html>
这是results.php
中的脚本,它尝试访问表单中的数据:
<?php
if(isset($_GET['venueName'])){
echo "yes";
}
else{
echo "not set";
}
?>
注意 - 运行时会回显未设置。
Also note, the function loadCatering()
simply loads results.php
using jQuery.If you would lke to see the contents of this function please let me know
试试这些1) 在表单标签中插入名称和方法
" <form name="submit" action="result.php" method="GET" onsubmit="loadCatering();return false;" >
2)在按钮标签中也插入相同的名称
" <input type="submit" name="submit">submit</button><br>
然后使用这个访问if(isset($_POST['submit'])){
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.