Simple field value manipulation
Originally made for user look4php in SO. Who sadly deleted his question. But still, maybe could use it some day in the future.
by hobobne
HTML
<input type="text" name="ordernum" value="1" size="1" /> <span class="moveup">MoveUp</span> / <span class="movedown">MoveDown</span>
CSS
.moveup,
.movedown {border-bottom: 1px dotted #000000; font-size: 11px; cursor: pointer;}
JavaScript
$('.moveup, .movedown').click(function () {
var ordernum = $('input[name=ordernum]');
if ($(this).hasClass('moveup')) {
ordernum.val(parseInt(ordernum.val()) + 1);
} else if ($(this).hasClass('movedown')) {
// Limits at 0
if (parseInt(ordernum.val()) >= 1) {
ordernum.val(parseInt(ordernum.val()) - 1);
}
}
});