To all;
I have created a up and down counter for decimal places and when a change occurs I have it force a blur event to recalculate fields with the following code:
$('button').click(function(){
var decPlaces = document.calculator.dpv.value * 1;
var hii = document.calculator.origin.value;
if (this.id == 'up' && decPlaces < 9){
document.calculator.dpv.value = decPlaces + 1;
if (hii != ''){
document.calculator[hii].focus();
document.calculator[hii].blur();
}
}
if (this.id == 'down' && decPlaces > 0){
document.calculator.dpv.value = decPlaces - 1;
if (hii != ''){
document.calculator[hii].focus();
document.calculator[hii].blur();
}
}
Works well in FF but drags in others particularly IE - suggestions on making the cleaner and faster is appreciated.
Bob
The official jquery way to trigger/force an event is
$("selector").trigger("blur");
$("selector").trigger("focus");
But I'm not sure this is what will help you.
You're mixing jQuery and DOM calls, you should really avoid doing that.
Create specific handlers for the Down and Up buttons (by using either ID tags or class tags) and then change the value of your calculator value by calling the jQuery $("#calculator").val(decPlaces + 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With