<form name="form3" action="priority.php? id=<?php echo $row['id'] ?>" method="post">
<select name="taskOption2" id="taskOption2" onchange="this.form.submit();" >
<option selected disabled hidden> <?php echo $row['priority'] ?> </option>
<option value="High">High</option>
<option value="Normal">Normal</option>
<option value="Low">Low</option>
</select>
<noscript><input type="submit" value="Submit" > </noscript>
</form>
如何在没有页面刷新的情况下提交表单?谢谢
答案 0 :(得分:0)
<form id="formid" name="form3" action="priority.php? id=<?php echo $row['id'] ?>" method="post">
<select name="taskOption2" id="taskOption2" onchange="this.form.submit();" >
<option selected disabled hidden> <?php echo $row['priority'] ?> </option>
<option value="High">High</option>
<option value="Normal">Normal</option>
<option value="Low">Low</option>
</select>
<noscript><input type="submit" value="Submit" > </noscript>
</form>
<script>
$("#formid").submit(function(e) {
var url = "path/to/your/script.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#formid").serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
<script>