Andy_con
ClioSport Club Member
clio 182
so this is my sum (taken from an excel spreadsheet) - =(B13*B14)+(B13*B13)/(2*(B15+(0.1*B16)))
someone wrote some java script for me to do this same sum, but im not getting the right result, can anyone help as to why?
/**
* Notification that the UI is about to transition to a new page.
* Perform custom prepage-transition logic here.
* @param {String} currentPageId
* @param {String} targetPageId
* @returns {boolean} true to continue transtion; false to halt transition
*/
phoneui.prePageTransition = function(currentPageId,targetPageId) {
// add custom pre-transition code here
// return false to terminate transition
return true;
}
/**
* Notification that the UI has transition to a new page.
*
* @param {String} newPageId
*/
phoneui.postPageTransition = function(newPageId) {
}
/**
* Notification that device orientation has changed.
*
* @param {String} newOrientation
*/
phoneui.postOrientationChange = function(newOrientation) {
}
/**
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
}
function updateTotal() {
//read arg1-arg4 input values
// inspect the html file to get the field IDs
var arg1 = parseInt($('#m1-sum-arg1Field').val(), 10);
var arg2 = parseInt($('#m1-sum-arg2Field').val(), 10);
var arg3 = parseInt($('#m1-sum-arg3Field').val(), 10);
var arg4 = parseInt($('#m1-sum-arg4Field').val(), 10);
//convert all non-numeric (NaN) inputs to 0
arg1 = isNaN(arg1) ? 0 : arg1;
arg2 = isNaN(arg2) ? 0 : arg2;
arg3 = isNaN(arg3) ? 0 : arg3;
arg4 = isNaN(arg4) ? 0 : arg4;
//compute sum of args
sum = (arg1*arg2)+(arg1*arg1)/(2*(arg3+(0.1*arg4)));
//display total
$('#m1-sum-totalText').text(sum);
}
function clearArg(argNum) {
id = '#m1-sum-arg' + argNum + 'Field';
$(id).val('');
updateTotal();
}
so the two sums side by side
=(B13*B14)+(B13*B13)/(2*(B15+(0.1*B16)))
=(arg1*arg2)+(arg1*arg1)/(2*(arg3+(0.1*arg4)));
someone wrote some java script for me to do this same sum, but im not getting the right result, can anyone help as to why?
/**
* Notification that the UI is about to transition to a new page.
* Perform custom prepage-transition logic here.
* @param {String} currentPageId
* @param {String} targetPageId
* @returns {boolean} true to continue transtion; false to halt transition
*/
phoneui.prePageTransition = function(currentPageId,targetPageId) {
// add custom pre-transition code here
// return false to terminate transition
return true;
}
/**
* Notification that the UI has transition to a new page.
*
* @param {String} newPageId
*/
phoneui.postPageTransition = function(newPageId) {
}
/**
* Notification that device orientation has changed.
*
* @param {String} newOrientation
*/
phoneui.postOrientationChange = function(newOrientation) {
}
/**
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
}
function updateTotal() {
//read arg1-arg4 input values
// inspect the html file to get the field IDs
var arg1 = parseInt($('#m1-sum-arg1Field').val(), 10);
var arg2 = parseInt($('#m1-sum-arg2Field').val(), 10);
var arg3 = parseInt($('#m1-sum-arg3Field').val(), 10);
var arg4 = parseInt($('#m1-sum-arg4Field').val(), 10);
//convert all non-numeric (NaN) inputs to 0
arg1 = isNaN(arg1) ? 0 : arg1;
arg2 = isNaN(arg2) ? 0 : arg2;
arg3 = isNaN(arg3) ? 0 : arg3;
arg4 = isNaN(arg4) ? 0 : arg4;
//compute sum of args
sum = (arg1*arg2)+(arg1*arg1)/(2*(arg3+(0.1*arg4)));
//display total
$('#m1-sum-totalText').text(sum);
}
function clearArg(argNum) {
id = '#m1-sum-arg' + argNum + 'Field';
$(id).val('');
updateTotal();
}
so the two sums side by side
=(B13*B14)+(B13*B13)/(2*(B15+(0.1*B16)))
=(arg1*arg2)+(arg1*arg1)/(2*(arg3+(0.1*arg4)));