Adding numbers
I have a form with 2 number boxes (NumberBox1, NumberBox2)
I have a button that has a javascript function (testFour)
I am trying to get the values from each box, add them and display the sum in a messagebox.
When I get the values from each Number Box, they are concatenated, not added
Here is my function
function testFour(){
//get each value and sum them and display them
var options = {};
var num1 = 0;
var num2 = 0;
var answer = 0;
//get the value...
//
options.fieldId = 'NumberBox1';
eFormHelper.getFieldValue (options, function (result)
{
if (result.isSuccess) //check if is success
{
console.log(result.data); //logs the data holds the found control's value
num1 =result.data;
}
else
{
console.log(result.error); //logs the error
}
});
options.fieldId = 'NumberBox2';
eFormHelper.getFieldValue (options, function (result)
{
if (result.isSuccess) //check if is success
{
console.log(result.data); //logs the data holds the found control's value
num2 = result.data;
}
else
{
console.log(result.error); //logs the error
}
});
answer = num1 + num2;
options.value = answer
//now display it?
eFormHelper.confirmMessage(options, function (result)
{
if (result.isSuccess)
{
console.log(result.data); //logs the data holds the empty object
}
else
{
console.log(result.error); // logs the hold exception object
}
});
};//end function testFour
请先登录再写评论。
评论
1 条评论