Help with javascript
Posted: Mon Jul 15, 2013 3:46 pm
I have some code I got from someone for increasing and decreasing a quantity field with buttons. I'd like it to be able to make the quantity to go negative and also not have leading zeros. I'm not much on javascript. Any experts out there willing to lend a hand?
Thanks much!
Jim
Thanks much!
Jim
Code: Select all
function updateQty(button) {
var parts = button.id.split(".");
var textbox = getObj("INQTY." + parts[1]);
var value = Number(textbox.value);
if (isNaN(value)) value = 0;
if (parts[0] == "increaseQty") value += 1;
if (parts[0] == "decreaseQty") value -= 1;
if (value < 0) value = 0;
value = "000" + value;
value = value.substr(value.length - 3, 3);
textbox.value = value;
textbox.modified = true;
setTimeout(function() {
textbox.focus();
}, 1);
}