I am not a developer but occassionaly I have to edit and/or develop sites. I have libraries of scripts that I just edit some code and everything works fine. But right now I am having a issue: In my sharepoint list I have begin and end date. Using sharepoint desinger I was able to calculate month difference between those two dates. Till this point it is working fine. I also need to display a status like - if month > some month do this. Below is my code, I know it is the javascript but I couldn't figure out what. Any sort of help or information will be highly appreciated.
function getMyListDataCallback(xData){
-------------
}
var month = (year2-year1)*12+(month2-month1)-1;
var status = (function forwardback(fb){
if (fb > 45) {console.log("move forward");}
else if (fb <25 && fb > 0) {console.log("stay where you at");}
else if (fb <45 && fb > 30) {console.log("move backward");}
})
forwardback(month);
AddRowToTable(title,report,beginmonth,endmonth,month,status);
Every other data is displaying correctly in html table but the status column. It is displaying all codes in function instead of "move forward" and so on.
It looks like you're setting the status
variable to be equal to the forwardback
function definition.
You probably want to set it equal to the return value from the forwardback
function.
var status = forwardback(month);
AddRowToTable(title,report,beginmonth,endmonth,month,status);
function forwardback(fb){
if (fb > 45) { return "move forward";}
else if (fb <25 && fb > 0) { return "stay where you at";}
else if (fb <45 && fb > 30) { return "move backward";}
};