最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript Error: Expected ')' - Stack Overflow

programmeradmin2浏览0评论

getting this error:

at this line: totalFundedLabel.push( "label": "Funded");

JS:

var totalFunded =  '${totalFunded}';
var totalUnfunded =  '${totalUnfunded}';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": <tld-msst:fc-value var="${totalFunded}"/>);
totalFundedText.push( "toolText": "<fmt:formatNumber value='${totalFunded}' type='currency' groupingUsed='true' />");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": <tld-msst:fc-value var="${totalUnfunded}"/>);
unFundedText.push( "toolText": "<fmt:formatNumber value='${totalUnfunded}' type='currency' groupingUsed='true' />");
 }

RENDERED HTML:

var totalFunded =  '109321734.06';
var totalUnfunded =  '381234572.79';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": "109321734.06");
totalFundedText.push( "toolText": "$109,321,734.06");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": "381234572.79");
unFundedText.push( "toolText": "$381,234,572.79");
}

getting this error:

at this line: totalFundedLabel.push( "label": "Funded");

JS:

var totalFunded =  '${totalFunded}';
var totalUnfunded =  '${totalUnfunded}';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": <tld-msst:fc-value var="${totalFunded}"/>);
totalFundedText.push( "toolText": "<fmt:formatNumber value='${totalFunded}' type='currency' groupingUsed='true' />");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": <tld-msst:fc-value var="${totalUnfunded}"/>);
unFundedText.push( "toolText": "<fmt:formatNumber value='${totalUnfunded}' type='currency' groupingUsed='true' />");
 }

RENDERED HTML:

var totalFunded =  '109321734.06';
var totalUnfunded =  '381234572.79';

var totalFundedValue = [];
var totalFundedLabel = [];
var totalFundedText = [];

var unFundedValue = [];
var unFundedLabel = [];
var unFundedText = [];

if (totalFunded != null)  
{
totalFundedLabel.push( "label": "Funded");
totalFundedValue.push( "value": "109321734.06");
totalFundedText.push( "toolText": "$109,321,734.06");
}


if (totalUnfunded != null)  
{
unFundedLabel.push( "label": "unFunded");
unFundedValue.push( "value": "381234572.79");
unFundedText.push( "toolText": "$381,234,572.79");
}
Share Improve this question asked Jan 22, 2013 at 14:09 Doc HolidayDoc Holiday 10.3k32 gold badges102 silver badges153 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

That's a syntax error because, well, it is. You probably want:

unFundedLabel.push({ label: "unFunded"});

The curly braces create an object, with a property called "label". You don't need quotes on the property name if it looks like an identifier (usually). Looks like all your .push() calls are broken in that same way.

You had missing braces { & } in all the push statements

if (totalFunded != null)  
{
totalFundedLabel.push( {"label": "Funded"});
totalFundedValue.push( {"value": <tld-msst:fc-value var="${totalFunded}"/>});
totalFundedText.push( {"toolText": "<fmt:formatNumber value='${totalFunded}' type='currency' groupingUsed='true' />"});
}


if (totalUnfunded != null)  
{
unFundedLabel.push( {"label": "unFunded"});
unFundedValue.push( {"value": <tld-msst:fc-value var="${totalUnfunded}"/>});
unFundedText.push( {"toolText": "<fmt:formatNumber value='${totalUnfunded}' type='currency' groupingUsed='true' />"});
 }
发布评论

评论列表(0)

  1. 暂无评论