Well this is supposed to be a simple one but have been giving me headache for two days now. I have the following:
<a href="javascript:void();" onclick="return manage(id, value)">Add or remove</a>
The manage function is as follow
function manage(id, param){
var my_value;
alert(my_value); // this keeps giving me undefined. I want it to hold the last value of the param
if(param!=0){ // value not empty, we are removing
my_value = remValue(id, param);
}
else if(param==''){ // value is empty, so we are adding
my_value = addValue(id, param);
}
alert(my_value);
}
function addValue(id, param){
param += 1;
return param;
}
function remValue(id, param){
param -= 1;
return param;
}
The whole idea is to assign the value of param to my_value after the adding or removing operation. Any help please?