[英]Using service call getting data from sharepoint list data and displaying in html table, everything is working but one javascript is failing
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. 使用sharepoint desinger,我能够计算出这两个日期之间的月份差。 Till this point it is working fine. 到此为止,它工作正常。 I also need to display a status like - if month > some month do this. 我还需要显示一个状态,例如-如果month> some month,请执行此操作。 Below is my code, I know it is the javascript but I couldn't figure out what. 下面是我的代码,我知道它是JavaScript,但我不知道是什么。 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. 除status列外,所有其他数据均在html表中正确显示。 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. 看起来您正在将status
变量设置为等于forwardback
函数定义。
You probably want to set it equal to the return value from the forwardback
function. 您可能希望将其设置为等于forwardback
函数的返回值 。
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";}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.