I'm having a problem on getting the customer's name. I have this code on php
<label>Select Customer :</label>
<input list="customer_list" id = "s_cust" name = "s_cust" type="text" onblur ="setCustName();">
<label id="cust_name" name = "cust_name"></label>
<datalist id="customer_list">
<?php
$result= $mysqli->query("SELECT * FROM tbl_customers");
while ($row = $result->fetch_assoc()) {
echo "<option value =
".$row['CustomerID'].">".$row['FirstName']." ".$row['MiddleName']."
".$row['LastName']."</option>";
}
?>
</datalist>
and I have a javascript
function setCustName() {
document.getElementById('cust_name').innerText = document.getElementById('customer_list').value;
}
I want to do is get the selected value based on the datalist. I tried this code but giving me undefined data. Help me Guys.