如何从输入中获取价值而无需提交并从datalist中搜索
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何从输入中获取价值而无需提交并从datalist中搜索相关的知识,希望对你有一定的参考价值。
> This Is My html CODE
<label>Person</label>
<input name="PersonID" type="text" id="PersonID">
<label>Car Plate Number</label>
<input name="PersonsCarPlateNumber" list="PersonsCarPlateNumber" type="text" />
> This is My php CODE
<?php
$conn = mysqli_connect("localhost", "root", "", "PersonWithCars");
$result = $conn->query("SELECT CarPlateNumber FROM Persons WHERE ID = '***PERSONID***' ");
?>
> This Is My Data List Where The Search For Persons Car
<datalist id=PersonsCarPlateNumber>
<?php while ($row = $result->fetch_assoc()):?>
<?php unset($CarPlateNumber);
$CarPlateNumber = $row['CarPlateNumber'];?>
<option value="<?php echo $CarPlateNumber?>"></option>
<?php endwhile;?>
</datalist>
- 需要帮助对不起我的代码搞砸了,只是初学者在这里学习 是PersonID,PersonsCarPlateNumber
答案
<!-- date picker -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
<!-- 2 decimal places -->
<input onchange='fixit(this)'>
<script>
function fixit( obj ) {
obj.value = parseFloat( obj.value ).toFixed( 2 )
}
</script>
<!-- query -->
<?php
$conn = mysqli_connect("localhost","root","","employeesystem");
$checkid = "SELECT * FROM student WHERE studid = '$studid'";
$result = $conn->query($checkid);
/*query with rows*/
$checkid = "SELECT * FROM student WHERE studid = '$studid'";
$result = $conn->query($checkid);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$stud = $row['studname'];
}
}
?>
<!-- for table row display -->
<table style="width:100%">
<tr>
<th>empid</th>
<th>name</th>
<th colspan="3">combine</th>
</tr>
<?php while($row = mysqli_fetch_array($result)):?>
<tr>
<td><center><?php echo $row['studid'];?></center></td>
<td><center><a href="viewstud.php?studid=<?php echo $row['studid'];?>">view</a></center></td>
</tr>
<?php endwhile;?>
</table>
以上是关于如何从输入中获取价值而无需提交并从datalist中搜索的主要内容,如果未能解决你的问题,请参考以下文章
如何在服务器上提交更改并从代码存储库中提取更新而不会发生冲突?