I tried to write codes of to display value in texbox but that value is displed based on selected value from combox that works fine,
But what I want now is if I select ItemCode from combobox I need ItemPrice to be displayed in the textbox
What I have now is if I select Item the value which is between <option>**Item Name**</option>
is displayed in that textbox instead ItemPrice
Below is my sample codes which runs fine
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" /></script>
<span id="spanSegmentData">
<?php
require_once('connection.php');
$queItem = mysqli_query($connect, "select * from oitm");
echo "<select name=\"segment_id\" class=\"form-control\" id=\"segment_id\" STYLE=\"width: 300px\" >";
echo "<option value=\"\" selected=\"selected\">Select a product</option>";
while ($rowStockIn = mysqli_fetch_array($queItem)) {
$ItemCode2 = $rowStockIn['ItemCode'];
$ItemName2 = $rowStockIn['ItemName'];
$ItemPrice2 = $rowStockIn['ItemPrice'];
echo "<option value=\"$ItemCode2\">$ItemCode2 $ItemName2</option>";
}
echo "</select>";
?>
</span>
<span id="dt_title"> <input id="title" name="title" type="text" value="<?php echo "$ItemPrice2";?>" data-title="MB" style="width:300px" readonly> </span>
<script>
$("#segment_id").change(function () {
var id = $(this).val();
$("#title").val($("#segment_id option:selected").text());
});
</script>
Sample of my form I want to allow all rows to display value in textbox based on value selected in combobox Please anyone can help me to display that ItemPrice in the textbox