myForm.setItemValue - no Save

myForm.attachEvent("onButtonClick", function(id){
        var res, num1, num2;
	num1 = parseInt(myForm.getItemValue("firstNum"));// returns the value of item
	num2 = parseInt(myForm.getItemValue("secNum")); // returns the value of item
	if (id=="plus") //defines addition
		{ res=num1+num2;}
	else if (id=="minus") //defines subtraction
	else if (id=="multiply")//defines multiplication
	else if (id =="divide")//defines division
		{  if (num2==0) //if division by zero - generates a message
		       {alert("Error.Division by zero!");res="";}
		   else {res=num1/num2;}
	myForm.setItemValue("resNum",res);// sets the value of item

resNum receives the value does not update the database. Updates only when I type (form editing)

could you provide complete initialization code?
Are you using dataprocessor to save data on the server side?