“消息:预期')'”但这似乎不对

时间:2013-12-16 09:10:32

标签: javascript syntax-error

我有这段代码:

function createTable(tabletop, tableside, gridbutton, tabletype){
var spinner = createSpinner();
var table = '<table><tr><th> &nbsp; </th>'; 

for(var j = 0; j < tabletop.length; j++){   
table +='<th scope="col">' + tabletop[j]+ '</th>'; // creates tableheader horizontally 
}
table+='</tr>';

for(var i = 0; i < tableside.length; i++) {
table+='<tr><th>' + tableside[i]  + '</th>' ; // creates table header vertically
for(var j = 0; j < tabletop.length; j++){    // inserts tablecell 
table +='<td>';

function createButtons(tabletop[j], tableside[i], tabletype){
var rolebuttons = new Array();
var phasebuttons = new Array();
var systembuttons = new Array();

for(var i = 0; i < Articles.length; i++){ 
if(tabletype == 'role'){ 
 if(contains(Article[i].System, tabletop[j] && Article[i].Phase, tableside[i])){ 
  $.each(rolebuttons, function(i, a){ 
  if($.inArray(a, rolebuttons) === -1) rolebuttons.push(a);
  )};

table += '<input type="button" value="'+ rolebuttons[i] + '" class="'+ tabletype  +'button" onclick="createListView(\'' + rolebuttons[i] + '\', \'' + tabletop[j] +'\', \''+ tableside[i] +'\', \'role\');"/>';

}
}else if(tabletype == 'phase'){      
 if(contains(Article[i].System, tabletop[j] && Article[i].Role, tableside[i])){
 $.each(phasebuttons, function(i, a){ 
 if($.inArray(a, phasebuttons) === -1) phasebuttons.push(a);
 )};
 }else if(tabletype == 'system'){ 
  if(contains(Articles[i].Role, tabletop[j] && Article[i].Phase, tableside[i])){
  $.each(systembuttons, function(i, a){¨
  if($.inArray(a, systembuttons) === -1) systembuttons.push(a);
  )};   
 }  
  }
   }
    }
 table += '</td>';   
 }
 table += '</tr>';
     }
 table+=('</table>');
 $('body').html('<div class="wrapper">' + table + spinner + '</div>');       
 return table; 
 }

我继续收到消息:预期')'在第xxx行xxx(在桌面变量的中间): 这一行:

 function createButtons(tabletop[j], tableside[i], tabletype){ 

但我真的不知道问题是什么?

我失明了吗? :)

你可以帮我解决一下:)

1 个答案:

答案 0 :(得分:0)

首先,您的代码中存在一些语法错误;我假设你不小心在你的代码中包含了一些其他字符。

例如,语音标记不应出现在此处:

$.each(systembuttons, function(i, a){¨

关于您的问题,参数名称不能包含括号。我可以理解你在运行原始循环时想要做什么,然后你认为你可以获得当前的循环迭代,但这不是它的工作方式。

我认为你不需要创建一个名为“createButtons”的函数。我只想在原始循环中包含函数的内容。

另外,只是一个提示 - 尽量不要直接作为侮辱,我确信评论员并不是故意粗鲁,他/她只是保持直接指向直截了当。它使我们所有人都能更快地得到正确答案:)