How are you setting the variable? You could be able to set the variable by doing the following:
variableName.value = "value";
Note that all variables are strings. So to do arithmetic, you must cast the variable to a number then cast back to a string prior to assignment.
//increment variableName by one
variableName.value = (parseInt(variableName.value) + 1) + "";
Also note that variables do not retain their state when a form is saved in Acrobat / Reader, so it cannot be relied on for forms that can be saved and revisited.