Problem with increment and decrement buttons

my friends, i’am a newbie, in javascript programming and i have some trouble doing some things. I post a path to a image to help understand the idea.enter link description here

the problem is…
I have a checklist that enables a input text box with a button increment and decrement, when active the box below to add items the field top they are counting down The field above is also active, return to the top of the field and increase one unit and he jumps two units, the increased in the lower box over the top.
code:

function id( el ){
  return document.getElementById( el );
}

function check(checkbox){
	if(checkbox.checked){	
	 alert('increment'+ checkbox.id);	 	

	 /*quantidade*/
	
	 /*increment button*/
	 id('increment'+ checkbox.id).onclick = function(){

	 if( id('text-field'+ checkbox.id).value < max_unit)
	 valor+=1;
	 id('text-field' + checkbox.id).value = valor;	

	 document.getElementById('qnt_'+checkbox.id).innerHTML= valor; 

	 }
	 
 	 /*decrement button*/
	 id('decrement'+ checkbox.id).onclick = function(){
	 if( id('text-field'+ checkbox.id).value > 1)
	 valor-=1;
	 id('text-field' + checkbox.id).value = valor;
	}	 
}
/*end if*/
	else{
	valor=1;
	document.getElementById('decrement'+checkbox.id).disabled=true;
}
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.