I want to display value in textbox from database but the value based on selected value from combobox. Below are sample codes but I do know how to use value from database in array of jquery
<html>
<head>
</head>
<body>
<form id="taxDetails">
<select name="ItemCode" onchange="setTax(document.Form, this.value);">
<option value="">Select an Item from List...</option>
<option value="AB">Pen</option>
<option value="BC">Book</option>
<option value="ON">Note book</option>
</select>
<input name="showtax" type="text" id="showtax" value="<show-value-of-tax-here" />
</form>
<script>
var taxCodes = {
'AB': 5,
'BC': 12,
'ON': 13
};
var form = document.getElementById('taxDetails');
form.elements.ItemCode.onchange = function () {
var form = this.form;
form.elements.showtax.value = taxCodes[this.value];
};
</script>
</body>
</html>
Below is my query I want to use
$q= mysqli_query($connect,"select ItemCode, UnitPrice from oitm");
I do know how I can use the value from database in the following codes
<script>
var taxCodes = {
'AB': 5,
'BC': 12,
'ON': 13
};
What I want is to select ItemCode and then display UnitPrice in textbox from above query
Please anyone can help me