I am trying to multiply the contents of a text box called qty1 by the price in a select box that is retrieved using ajax.
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#stock1').on('change', function (){
var newValue1 = $.getJSON('select2.php', {stockID: $(this).val()}, function(data){
var options = '';
for (var x = 0; x < data.length; x++) {
options += data[x]['priceeach'];
}
$('#priceeach1').text(options);
var qty1 = $("#qty1").text();
var priceeach1 = $("#priceeach1").text();
$('#linetotal1').text(priceeach1 * qty1);
});
});
});
</script>
<script>
The script changes the values in this html :
Price Each : £<span id="priceeach1"></span> - Line Total : £<span id="linetotal1"></span>
The priceeach1 values are changed, but the linetotal1 value stay at 0, even when the select box is changed or the values in qty1 are changed. What should happen is priceeach1 from the drop down is multiplied by the text box qty1. For example if the priceeach1 = 20.00 and the qty1 was 2 linetotal1 would be 40.00 , but all I get at present is 0 .