我正在使用这些代码,但我需要加载在文本框中键入的数据,而无需按 Enter 或提交按钮。
这是我的 aaa.php
文件。我正在使用这个系统作为条形码扫描仪:)
输入条形码
</table>
</form>
<hr />
<?php
require_once('dbconnect.php');
$txtbarcode=$_POST['barcode'];
$result=mysql_query("SELECT * from barcode where itemcode='".$txtbarcode."'");
echo "<center><table border=1>";
echo"<tr><th>ITEM CODE:</th><th>ITEM:</th><th>QTY</th><th>SRP</th><th>MARKUP RATE</th><th>SELLING PRICE</th></tr>";
while($row=mysql_fetch_array($result))
{
echo"<tr>";
echo "<td align= center>".$row['itemcode']."</td>";
echo "<td align=center>".$row['item']."</td>";
echo "<td align=center>".$row['qty']."</td>";
echo "<td align=center>".$row['srp']."</td>";
echo "<td align=center>".$row['markup']."</td>";
echo "<td align=center>".$row['sp']."</td>";
echo"</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
最佳答案
例如,在输入元素上使用“onchange”事件。
<input type="text" id="barcode" name="barcode" onchange="postData(this)" />
然后您就可以通过 AJAX 做任何您想做的事情。
function postData(my_object){
$barcode = my_object.value;
// ...
}
关于javascript - 如何在不使用提交按钮的情况下从文本框加载输入? JavaScript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22127398/