Ajax脚本
<script>
function tankdip(str) {
if (str == "") {
document.getElementById("open").innerHTML = "";
return;
} else {
var num = parseFloat(str);
var tank = document.getElementById("pumps"+count).value;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("open").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","open.php?open="+num+"&tank="+tank,true);
xmlhttp.send();
}
}
</script>
HTML表格
<td><input type="text" name="odip[]" id="odip" data-srno="1" class="form-control input-sm " onkeyup="tankdip(this.value)" required></td>
<td><select name="open[]" id="open" data-srno="1" class="form-control input-sm " readonly></select></td>
open.php
<?php
include "connect.php";
$con=mysqli_connect("$host", "$username", "$password","$db_name")or die("Your Connection is in error");
$open = $_GET['open'];
$tank = $_GET['tank'];
$sql = mysqli_query($con,"SELECT dip,cap from $tank where dip = '$open'");
while ($row = mysqli_fetch_array($sql))
{
$combo.="<option >" . $row[1]. "</option>";
}
echo $combo;
?>
我想使用ajax获取对应的“ odip”值的“ open”值。但是当我尝试发送float(12.34)时就变成(12)。我希望日期以Float发送。
答案 0 :(得分:0)
尝试
function tankdip(str) {
console.log("Input str:", str);
您确定str
是浮动的吗?
也可能是某些表中的dip
字段具有INT类型吗?