So how do I actually save 2 different values into the database?
Below is code work for display the string beside the selection. I use javascript to read the value and display for this and when i try to save it only save the string
Code: Select all
<div class="container mb-2">
<div class="row g-2 align-items-center">
<div class="col-6">
<select class="form-control" id="credit_code" name="credit_code">
<option selected disabled value="">Credit Account No >></option>
<option value="CIMB">3020</option>
<option value="Electronics/Gadgets">3335</option>
<option value="Motor Vehicles">3330</option>
</select>
<span style="color:red; font-size:15px;"><?= $errors['credit_err'] ?></span>
</div>
<div class="col-6">
<span class="form-text" style="font-size:16px;">
<input class="form-control-plaintext" type="text" id="credit_name" name="credit_name" onclick="credit_value()" readonly>
</span>
</div>
</div>
</div>
Code: Select all
var select2 = document.getElementById('credit_code');
var input2 = document.getElementById('credit_name');
select2.onchange = function() {
input2.value = select2.value;
}
Code: Select all
<select class="form-control" id="credit_code" name="credit_code">
<option selected disabled value="">Credit Account No >></option>
<option value="3020" data-credit_name='"CIMB" data-credit_code=3020>3020</option>
</select>
Can anybody help me with my code? I don't know how to save the separate data to the 2 different columns in the database and when the selection option select it should display a string beside it.