gpt4 book ai didi

javascript - 填充数据库字段后禁用提交按钮

转载 作者:行者123 更新时间:2023-11-28 02:44:39 25 4
gpt4 key购买 nike

我创建了一个带有提交按钮的表单。如果特定产品的“价格”已经填写,则必须禁用提交按钮:

enter image description here

PHP 代码

<?php
$host="localhost";
$username="root";
$password="";
$db_name="ge";

$con=mysqli_connect("$host", "$username", "$password","$db_name")or die("Your Connection is in error");
$sql="SELECT pname,catogery,email FROM quetation WHERE catogery = '$catogery'";

$results=mysqli_query($con,$sql);
$count=mysqli_num_rows($results);
if($count == 0) {
echo "<font color=\"#0000\"><h1 align=\"center\">No details found</h1></font>";
} else {
$resource=mysqli_query($con,$sql);
echo "<font color=\"#000000\">
<h2 align=\"center\"></h2>
<table align=\"center\" border=\"1\" width=\"50%\">
<tr>
<td><b>ProdName</b></td>
<td><b>Catogery</b></td>
<td><b>Price</b></td>
</tr> ";
while($result=mysqli_fetch_array($resource)) {
echo "
<div class=\"row\">
<div class=\"input-field col s12\">
<tr>
<td>".$result[0]."</td>
<td>".$result[1]."</td>
<td>
<form name=\"abc\" methos=\"post\" action=\"postprice.php\">
<input type=\"submit\" value=\"send\">
</form>
</td>
</div>
</div>
</tr>";
} echo "</table></font>";
}
?>

如果已经输入价格,则只应输入一次价格,然后应禁用发送按钮

每当我加载这个页面时,它应该检查数据库,如果价格值被填充,那么它应该禁用发送按钮。

最佳答案

在提交按钮中使用以下代码:

<input type="submit" onClick="this.disabled=true;">

这将在单击提交按钮后禁用该按钮。希望对你有帮助。

PLz 试试这个代码,希望它能工作。

<?php
$host="localhost";
$username="root";
$password="";
$db_name="ge";

$con=mysqli_connect("$host", "$username", "$password","$db_name")or die("Your Connection is in error");




$sql="SELECT pname,catogery,email,price FROM quetation WHERE catogery = '$catogery'";

$results=mysqli_query($con,$sql);

$count=mysqli_num_rows($results);
if($count == 0)
{
echo "<font color=\"#0000\"><h1 align=\"center\">No details found</h1></font>";
}
else
{
$resource=mysqli_query($con,$sql);
echo "<font color=\"#000000\">
<h2 align=\"center\"></h2>

<table align=\"center\" border=\"1\" width=\"50%\">
<tr>
<td><b>ProdName</b></td>
<td><b>Catogery</b></td>
<td><b>Price</b></td>

</tr> ";

while($result=mysqli_fetch_array($resource))
{
echo "

<div class=\"row\">
<div class=\"input-field col s12\">
<tr>
<td>".$result[0]."</td>
<td>".$result[1]."</td>
<td><form name=\"abc\" methos=\"post\" action=\"postprice.php\">";
if($result[3]==''){
echo "<input type=\"submit\" value=\"send\" onClick='this.disabled=true;'>";
} else {
echo "<input type=\"submit\" value=\"send\" disabled>";
}
echo "</td>
</form>
</div>
</div>
</tr>";
}echo "</table></font>";
}

?>

关于javascript - 填充数据库字段后禁用提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42128890/

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