Reputation: 779
I'm using JQuery PriceFormat Plugin (http://jquerypriceformat.com/).
My code is as following:
$('#valor').priceFormat({
prefix: 'R$ ',
centsSeparator: ',',
thousandsSeparator: '.',
limit: 8,
centsLimit: 2
});
However, but I want to be capable of changing a value of another input while the users type the value. For example, the input that I'm using priceFormat in, is a product price. But, there is another input called taxes, for example, that is dinamically changed by the price (let's say that the tax is 1% of the price). I want to be capable of changing the tax value while the user change the product price.
How can I do this?
Upvotes: 0
Views: 1187
Reputation: 2809
If you're trying to change the value of the tax rate as you are typing a value into product price then, you should tap into the keypress event for the product price textbox.
Here's the documentation for it along with an example: http://api.jquery.com/keypress/
Heres some pseudo code...
$(document).ready(function() {
$('#productPrice').keypress(function() {
var price = $('#productPrice').val();
// do comparisons with price to decide a tax rate...
$('#taxRate').val("8.375%");
});
});
Upvotes: 0
Reputation: 779
I have already solved this issued by binding the keyup event to a function like this:
function calcularTaxa(){
//code of function here
}
$("#valor").bind('keyup', calcularTaxa);
Hope this help someone. ;D
Upvotes: 0