I have a combobox which has a list of bank names and i am fetching it from DB.
I have one more combo box or a text box in which i want to display bank code. This bank code has to fill automatically for a corresponding bank name selected in 1st combo box.
i tried doing this, but its not working. Any help wil be greatly appreciated.
<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>";
?>