2012-02-04 54 views
0

当我在Firebug中检查这段代码时,整个块被禁用。什么使整个脚本块被禁用?

<script type="text/javascript"> 

var usercount = 0; 
var nbw = ''; 
$(document).ready(function() { 
    $('.alphabet').each(function() { 
     _$this = $(this); 
     nbw = $(this).val(); 
     $.ajax({ 
      type: "Get", 
      url: "cfc/basic.cfc?method=CountUsersByLetter&returnformat=json", 
      data: "nbw=" + nbw, 
      datatype: "html", 
      success: function (response) { 
       usercount = parseInt(response.substring(0, 10)); 
       $(_$this.target).attr('title', usercount); 
      }, 
      error: function (xhr, textStatus, errorThrown) { 
       alert('errorThrown'); 
      } 
     }); 
    }); 
    $('.StartOver').live('click', function() { 
     var ReInitAnswer = confirm('Are you sure you want TO DELETE ALL temp dupe records AND start over FROM SCRATCH? \nIt may take a couple OF hours.'); 
     if (ReInitAnswer) { 
      // submit the form TO BEGIN re-creating the temp table 
      document.forms["dupeIndivs"].submit(); 
      //return true; 
     } ELSE { 
      alert('canceled'); 
      return false; 
     } 
    }); 
    $('.notdupe').live('click', function (e) { 
     alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked")); 
     $.ajax({ 
      type: "POST", 
      url: "cfc/basic.cfc?method=SetNotDupe", 
      data: "indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"), 
      error: function (xhr, textStatus, errorThrown) { 
       // show error alert(errorThrown); 
      } 
     }); 
    }); 
    $('.alphabet').live('click', function (l) { 
     SelectedLetter = $(l.target).val(); 
     $(".alphabet").each(function (i) { 
      var CheckLetter = $(this).val(); 
      if (CheckLetter == SelectedLetter) { 
       $(this).css("background-color", "yellow"); 
       $('.NameBeginsWith').val(SelectedLetter); 
      } ELSE { 
       $(this).css("background-color", ""); 
      } 
     }); 
     $('.Reinit').attr('value', SelectedLetter); 
     $('.Reinit').trigger('click'); 
    }); 

</script> 
+0

你是什么意思 “禁用” 是什么意思? – 2012-02-04 18:43:51

+0

每行必须以四个空格作为前缀。块本身必须以空行为前缀。 – 2012-02-04 18:43:56

回答

1
  • 您有else替换所有大写ELSE(JavaScript是区分大小写)。
  • 在代码的末尾添加右括号和括号,以完成$(document).ready(function(){块。

工作代码:

<script type="text/javascript"> 

    var usercount = 0; 
    var nbw = ''; 
    $(document).ready(function() { 
     $('.alphabet').each(function() { 
      _$this = $(this); 
      nbw = $(this).val(); 
      $.ajax({ 
       type: "Get", 
       url: "cfc/basic.cfc?method=CountUsersByLetter&returnformat=json", 
       data: "nbw=" + nbw, 
       datatype: "html", 
       success: function (response) { 
        usercount = parseInt(response.substring(0, 10)); 
        $(_$this.target).attr('title', usercount); 
       }, 
       error: function (xhr, textStatus, errorThrown) { 
        alert('errorThrown'); 
       } 
      }); 
     }); 
     $('.StartOver').live('click', function() { 
      var ReInitAnswer = confirm('Are you sure you want TO DELETE ALL temp dupe records AND start over FROM SCRATCH? \nIt may take a couple OF hours.'); 
      if (ReInitAnswer) { 
       // submit the form TO BEGIN re-creating the temp table 
       document.forms["dupeIndivs"].submit(); 
       //return true; 
      } else { // <------------------------------------ ELSE > else 
       alert('canceled'); 
       return false; 
      } 
     }); 
     $('.notdupe').live('click', function (e) { 
      alert("indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked")); 
      $.ajax({ 
       type: "POST", 
       url: "cfc/basic.cfc?method=SetNotDupe", 
       data: "indivNum=" + $(e.target).val() + "&SetValue=" + $(e.target).is(":checked"), 
       error: function (xhr, textStatus, errorThrown) { 
        // show error alert(errorThrown); 
       } 
      }); 
     }); 
     $('.alphabet').live('click', function (l) { 
      SelectedLetter = $(l.target).val(); 
      $(".alphabet").each(function (i) { 
       var CheckLetter = $(this).val(); 
       if (CheckLetter == SelectedLetter) { 
        $(this).css("background-color", "yellow"); 
        $('.NameBeginsWith').val(SelectedLetter); 
       } else { // <------------------------------------ ELSE > else 
        $(this).css("background-color", ""); 
       } 
      }); 
      $('.Reinit').attr('value', SelectedLetter); 
      $('.Reinit').trigger('click'); 
     }); 
    }); // <---------------------------------------------------- Added }); 
</script> 
+0

就是这样。我只是想出了它。封闭的ELSE来自eclipse中使用“格式源”工具。很奇怪他们会这么做。再一次,非常感谢。我正在关闭出门的门。有人需要告诉Chris Kempen他是问题的一部分,而不是解决方案。 – user990016 2012-02-04 18:57:28

相关问题