Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript &引用;消息:预期为';)'&引用;但这并不意味着';似乎不对_Javascript_Syntax Error - Fatal编程技术网

Javascript &引用;消息:预期为';)'&引用;但这并不意味着';似乎不对

Javascript &引用;消息:预期为';)'&引用;但这并不意味着';似乎不对,javascript,syntax-error,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="

我有以下代码:

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; 
 }
但我真的看不出问题出在哪里

我失明了吗?:)


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

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

$.each(systembuttons, function(i, a){¨
关于您的问题,参数名称不能包含括号。我可以理解您在运行原始循环时要做什么,然后您会认为您可以获得当前循环迭代,但这不是它的工作方式

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


还有一个小提示——尽量不要把直截了当当作一种侮辱,我相信评论员并不是故意让人觉得他/她粗鲁,他/她只是为了直截了当地直截了当。它使我们能够更快地为您找到正确答案:)

[j]
[i]
在这里无效。参数/变量名称不能包含
[
]
。你想在这里做什么?这个问题似乎离题了,因为它是关于基本的Javascript语法的。因为规范这么说。你有没有见过一种语言,可以使用
[]
作为变量名的一部分?@Sally,这不是故意的粗鲁,这只是一个习惯性的接近原因。关于基本语法问题的问题对社区中的其他用户不是很有用,这就是我投票关闭你的问题的原因。@FrédéricHamidi所以如果我不帮助别人,我就不会问问题了?我来这里是为了找到我最终要求的答案,因为没有答案。。这不是本论坛的重点吗?另外,我不建议在循环中声明函数;一个函数应该更加自治。您应该在循环外部声明函数,然后从循环内部调用它。谢谢…:)我将尝试跳过函数部分并将其直接添加到循环中。。。我不是故意问一些愚蠢的问题,我这样做是因为我需要帮助,所以谢谢你!在按ask后的前10秒内,我被否决了3次,这让我非常恼火。是的,我只是这么做了,现在我又犯了其他错误,但是我以前见过的错误。没问题,很高兴我能帮上忙。
$.each(systembuttons, function(i, a){¨