[英]Retrieve data/record from the database using dropdown list without reloading
<form method="post" action="a.php">
<select name="taskOption">
<?php
include 'orderSelect.php';
echo '<option>View Order</option>';
while($row = mysqli_fetch_array($result)):;?>
<option value='<?php echo $row[0]; ?>'><?php echo $row[1]; echo " ";
echo $row[2]; ?></option>
<?php endwhile; ?>
<input type="submit" name="submit" value="click">
</select>
</form>
I want to retrieve a record/ data from the database when I select something from the dropdown list. 当我从下拉列表中选择某项时,我想从数据库中检索记录/数据。 Any advice on what to look up or code for this to be successful. 有关查找内容或成功编码的任何建议。
As suggested in OP tag you should be using ajax
Example with JQuery
below: 根据OP标记中的建议,您应该在下面的JQuery
中使用ajax
示例:
$('select["name=taskOption"]').change(function() {
var selected = $(this).val();
$.get('YOUR_FILE_WHICH_PROCCESS_RECORD.php',{selectVal:selected},function(data){
console.log(data);//this is the value from your php file.
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.