我有一个组合框,其中有一个银行名称列表,我从DB获取它。
我还有一个组合框或一个文本框,我想在其中显示银行代码。此银行代码必须自动填写在第一个组合框中选择的相应银行名称。
我试过这样做,但它不起作用。任何帮助都将不胜感激。
<label for="txtbankname"> Bank Name <em>*</em> </label>
<?php
include_once 'dbconnection.php';
$query1 = "SELECT BankName,BankId FROM bank_details";
$result1 = mysqli_query($connection, $query1);
echo "<select name='txtbankname'>";
while ($result2 = mysqli_fetch_assoc($result1)) {
echo "<option value='" . $result2['BankId'] . "'>" . $result2['BankName'] . "</option>";
}
$bkcode = $result2['BankId'];
echo $bkcode;
echo "</select>";
?>
<label for="txtbankcode"> Bank Code <em>*</em> </label>
<?php
include_once 'dbconnection.php';
$q2 = "SELECT BANKCODE FROM BANK_DETAILS ";
$rs1 = mysqli_query($connection, $q2);
echo "<select name='txtbankcode'>";
while ($rs2 = mysqli_fetch_assoc($rs1)) {
echo "<option value='" . $rs2['BANKCODE'] . "'>" . $rs2['BANKCODE'] . "</option>";
}
echo "</select>";
?>