Dharmeshdhabu
New member
I have a datalist and a textbox. When I change data in list, textbox change accordingly. Now I wish same to happen with multiple input like textbox, textarea, dropdown select etc. I do not wish to use dropdown select instead of datalist. Please guide me. Below is my code.
For example at present on changing "medicines", "dose" change accordingly. Now I wish that in other textarea "duration" also should change. Thanks
Code:
<input list="ff" class="form-control " onfocus="this.value=''" onchange="this.blur();" name="ffs" id="ffs">
<datalist id="ff">
<?php $result = mysqli_query($conn, "SELECT * FROM Source where Medicines is not null order by Medicines asc"); ?>
<?php while ($row = mysqli_fetch_array($result)) {
echo'<option data-value="'. $row["Dose"].'" value="'. $row["Medicines"].'">';
}
?>
</datalist>
<script type="text/javascript">
$("#ffs").on("change", function () {
var value = $('#ffs').val();
value = $('#ff [value="' + value + '"]').data('value');
$('#Dose').val(value);
});
</script>
For example at present on changing "medicines", "dose" change accordingly. Now I wish that in other textarea "duration" also should change. Thanks