HTML code:
<select name="ser" id="ser" class="form-control" onchange="getPrice(this.value);">
<option value="">--Select--</option>
<option value="Value11">Value1</option>
<option value="Value2">Value2</option>
</select>
<input type="text" name="sale" id="saleprice" class="form-control" />
<input type="text" name="sale" id="saletax" class="form-control" />
<input type="text" name="sale" id="avalqty" class="form-control" />
on my Js page:
function getPrice(val)
{
$.ajax({
type: 'post',
url: 'get_sales_price.php',
data: {
get_option:val
},
success: function (response) {
var valuesar = response.split("|");
$('#saleprice').val(valuesar[0]);
$('#saletax').val(valuesar[1]);
$('#avalqty').val(valuesar[2]);
}
});
}
This is my PHP page data:
$data = array();
$values=$variable1['value1'].'|'.$variable2['value2'].'|'.$variable3;
array_push($data, $values);
echo json_encode($data);
Value #saleprice: ["61.25 , and value <<24>: 155"] , and value #saletax: 1. #saletaxcorrect. How to get #saleprice: ["61.25 to 61.25 and #avalqty: 155"] to 155
source
share