Create crementing.js
function for in-/decrement on multiple templates, to be included in header somewhere
This commit is contained in:
parent
937f653313
commit
bcf418b9b5
1 changed files with 12 additions and 0 deletions
12
static/js/crementing.js
Normal file
12
static/js/crementing.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
this is thought for (de-/in)crement integer values in (e.g. input) form elements
|
||||||
|
calling like
|
||||||
|
<input type="input" value="++" onclick="crmnt(document.getElementById('id'),1)" />
|
||||||
|
<input type="input" value="+=5" onclick="crmnt(document.getElementById('id'),5)" />
|
||||||
|
<input type="input" value="-=5" onclick="crmnt(document.getElementById('id'),-5)" />
|
||||||
|
<input type="input" value="--" onclick="crmnt(document.getElementById('id'),-1)" />
|
||||||
|
*/
|
||||||
|
function crmnt( e, i ) { /* read: in-/decrement ( dom-element, signed-integer ) */
|
||||||
|
var d = parseInt( e.value ) + i;
|
||||||
|
e.value = ( d < 0 )? 0 : e.value = d;
|
||||||
|
}
|
Loading…
Reference in a new issue