【发布时间】:2026-01-26 21:20:02
【问题描述】:
我非常需要你的帮助。 我似乎找不到我的代码有什么问题。
情况是,我正在尝试根据我的组合框值填充我的文本框字段,并且它已连接到 sql 数据库中。我在网上尝试了一些代码,然后我找到了一个看起来准确的代码,但我似乎无法在我的文本框中显示结果。
这是我的 HTML 代码:
<?php
echo"Concept Store:";
echo "<select width='100' id='strs' name='strs' >";
echo "<option></option>";
while($row=sqlsrv_fetch_array($stmt))
{
$x= $row['strnm'];
echo " <option> $x</option>" ;
}
echo "</select>";
?>
Address    : <input type="text" id="add" name="add" size="27" /><br><br>
这里是 AJAX:
<script type="text/javascript">
$(document).ready(function(){
$('#strs').change(function(){
$.post("gadd.php",{strs:$(this.val() )},function(result){
$("#add").val(result);
});
});
});
</script>
这是我的“gadd.php”
<?php
session_start();
include ('sqlconn.php');
$gadd=$_post['strs'];
//$t1= mysql_real_escape_string($t1);
$sql="Select distinct dadd1 from ostore where strnm='".$gadd."' ";
$stmt = sqlsrv_query($conn,$sql);
//echo "<option></option>";
while ($row = sqlsrv_fetch_array($stmt))
{
// $type2=$row['dadd1'];
echo $row['dadd1'];
//echo '<option value ="'.$type2.'">'.$type2.'</option>';
}
?>
如果你能帮助我,那真是太棒了,谢谢!
【问题讨论】: