<option value="1" name="13.890000">Monster</option>
I would like to get name via javascript to do calculations (On change) (NOTE: NOT VALUE)
$("#calculateprice").on('change', function() {
x = $(this).children(':selected').attr('name');
z = x/1000;
});
<select id="calculateprice" name="serviceid" class="form-control">
<option selected disabled>Select a monster</option>
<option value="1" name="13.890000">Monster 1</option>
<option value="2" name="25.890000">Monster 2</option>
</select>
<input id="quantity" name="quantity" type="text" placeholder="" class="form-control input-md" required>
<input id="price" name="price" type="text" class="form-control input-md" disabled>
Now, I would like to get amount entered in QUANTITY and multiply with Z and show the result in PRICE.
SOLVED LIKE THIS:
var z;
var totalprice;
$("#calculateprice").on('change', function() {
x = $(this).children(':selected').attr('name');
z = x/1000;
});
$("#quantity").on('keyup', function() {
value = $("#quantity").val();
totalprice = z*value;
totalresult = parseFloat(Math.round(totalprice * 100) / 100).toFixed(2);
$('#price').val('$'+totalresult);
});
.nameattribute?name="13.890000"in option??