亲爱的用户在您的帮助和指导下,我已经实现了迄今为止。感谢这里的社区。有些用户觉得这是一个重复的问题 - 抱歉我改变了预期的结果。有了会员指导,我想我可以做到这一点。php如何保持其他领域不受干扰,同时填充组合
我有一个textarea,一个组合,一个文本框和其他元素的窗体。首先1)我在textarea中输入地址 2)我选择一个pincode - 从表 中填充pincode 3)当选择pincode时,下一个文本字段由上面第(2)点中使用的同一个表填充。 为此页面刷新pincode并在下一个文本框中显示该位置。 每个人都认为可以。但是我在textarea中输入的内容以及我在组合中选择的内容被刷新为空白。我需要替换我输入和选择的内容。 用于收集pin码
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.pin_code.options[form.pin_code.options.selectedIndex].value;
self.location='addschool.php?pin_code=' + val ;
}
</script>
下面的PHP代码的脚本:
<form data-toggle="validator" role="form">
<div class="form-group textareawidth has-feedback">
<label for="address">Enter school address</label>
<textarea class="form-control" pattern = "^[_A-z0-9]{1,}$" maxlength="150" rows ="3" name = "saddress" id="address" placeholder="Enter address with out pincode" required></textarea>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="help-block with-errors"></span>
</div>
<div class="form-group textareawidth">
<label for="pin">Pincode - School:</label>
<?php
echo "<select class='form-control' id='pin' onchange=\"reload(this.form)\" name ='pin_code' name=pin_code value='' >";
echo "<option selected='selected'>Select Pincode </option>";
while($nt=mysqli_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[pin]>$nt[pin]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
</div>
<?php
$vplace="";
if(isset($_GET['pin_code']))
{
$temp=$_GET['pin_code'];
$quer="SELECT place FROM pincode where pin = $temp ";
$ex1=mysqli_query($dbcon,$quer) or die(mysql_error());
$count1=mysqli_num_rows($ex1);
if($count)
{
$row = mysqli_fetch_assoc($ex1);
$vplace = $row["place"];
}
else
{
echo '<script>';
echo 'alert("no such place found");';
echo '</script>';
}
}
?>
<div class="form-group textareawidth">
<label for="place">Place</label>
<?php
//echo "<input type ='text' class='form-control' name = 'splace' id='place' value =$vplace]>;";
echo "<p class='form-control-static'>$vplace</p>";
?>
</div>
我怎样才能做到这一点?谢谢
顺便说一下,这看起来与您的其他问题http://stackoverflow.com/q/33786446/非常相似,并被视为重新发布。 –
可能的重复http://stackoverflow.com/questions/33786446/list-box-populating-but-not-working-php –
非常感谢接受答案的地方。我刚来这地方。 –