Reputation: 105
in a previous post, I received help with a jquery function that populates a textbox with a dropdown selection. I needed to use it to populate another textbox based on the same selection.
However, I need this textbox to have 2 decimal points and keep its value as a number because I will be using it in a calculation. Here is the code that populates the textbox:
<script>
$(function () {
$("#RaffleDollars").change(function () {
if ($(this).val() == "25")
$("#Total_Raffle").val(25);
});
});
</script>
How can I get the value of Total_Raffle
to display as 25.00 while keeping its format as a number used in a calculation?
Upvotes: 2
Views: 33
Reputation: 1
while keeping its format as a number used in a calculation?
input
element value is text , could convert to number object by casting with Number(value)
$("#RaffleDollars").change(function () {
if ($(this).val() == "25")
$("#Total_Raffle").val(25 + ".00");
});
Upvotes: 1