gpt4 book ai didi

html - Datalist 属性在谷歌浏览器中不起作用

转载 作者:行者123 更新时间:2023-11-28 02:57:01 27 4
gpt4 key购买 nike

Datalist 属性在 Google chrome 中不工作,在 Firefox 中工作正常

请看这里http://prntscr.com/arny81

提前感谢您的帮助。

HTML

<td><input onkeyup="showCustomers(this.value)" placeholder="Enter Customer Name" list="selectCust" name="Cno" />
<datalist id="selectCust">
</datalist>
</td>

Javascript

function showCustomers(str) {
if (str.length == 0) {
document.getElementById("selectCust").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("selectCust").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET", "getCustomers.php?q=" + str, true);
xmlhttp.send();
}
}

getCustomers.php文件

<?php include('conn.php'); ?>
<?php // get the q parameter from URL

$q = $_REQUEST["q"];
// lookup all hints from array if $q is different from ""
if ($q !== "") {
$q = strtolower($q);
$len=strlen($q);


$sql2 = 'SELECT Customer_Name as Cname,No from customers order by Customer_Name';
$result2 = mysqli_query($connection, $sql2) or die(mysqli_error($connection));

if (mysqli_num_rows($result2) > 0) {
?><option value=""></option><?php
// output data of each row
while($row2 = mysqli_fetch_assoc($result2)) {
if (stristr($q, substr($row2["Cname"], 0, $len))) { ?>
<option value="<?php
echo $row2['No']; ?>"><?php echo $row2["Cname"]; ?></option>
<?php } } ?>
<?php } } ?>

我根本没有用过 CSS。

最佳答案

改为在您的 CSS 中定位 ID,这应该可以正常工作。

HTML:

<datalist id="dl">
Your content goes here
</datalist>

CSS:

#dl {
display: block;
}

这在 Chrome 或任何其他浏览器中都可以正常工作。

关于html - Datalist 属性在谷歌浏览器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36593924/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com