2011-02-10 201 views
0
function GenerateTermSheet() 
     { 
      var urlString = "<%= System.Web.VirtualPathUtility.ToAbsolute("~/mvc/Indications.cfc/RenderPartialTermSheetView/")%>" 
      $("#termSheetPopup checkbox:checked").each(function(){ 
       alert("Clicked"); 
       var json = 
       { 
        id : GetGUIDValue(), 
        name : $(this).attr("name") 
       } 
       $.ajax({ 
        type: "POST", 
        url: urlString, 
        data: json, 
        success: function(data) { 

        } 
       }); 

      }) 
     } 

我從來沒有看到警報出現。如果我把它放在上面的每一行上,它就會出現,所以我知道這是我猜測的檢查框循環的問題。我做對了嗎?這裏是它循環的div:JQuery複選框循環不起作用

<div id="termSheetPopup"> 
         <div style="text-align:center;"> 
          <select id="termSheetType"> 
           <option>Internal</option> 
           <option>Borrower Facing</option> 
          </select> 
         </div> 
         <input type="checkbox" name="SummaryInformation">Summary Information<br /> 
         <input type="checkbox" name="ProductLegs">Product Legs<br /> 
         <input type="checkbox" name="AmortizationOptions">Amortization Options<br /> 
         <input type="checkbox" name="Values">Values<br /> 
         <input type="checkbox" name="Rates">Rates<br /> 
         <input type="checkbox" name="RatesSpecific">Rates (All-In-Rate, PV01)<br /> 
         <input type="checkbox" name="AmortizationSchedule">Amortization Schedule<br /> 
         <input type="checkbox" name="SponsorInfo">Sponsor/Affiliate Info<br /> 
         <input type="checkbox" name="BorrowerInfo">Borrower Info<br /> 
         <input type="checkbox" name="SponsorContacts">Sponsor/Affiliate Contacts<br /> 
         <input type="checkbox" name="CashFlows">Cash Flows<br /> 
         <input type="checkbox" name="PrePayment">Pre-Payment<br /> 
         <input type="checkbox" name="FutureExposure">Potential Future Exposure<br /> 
         <input type="checkbox" name="FutureExposureSpecific">Potential Future Exposure (Max Number and Date Only)<br /> 
         <input type="checkbox" name="History">History<br /> 
        </div> 

謝謝。

編輯:

調用GenerateTermSheet()位置:

$('#termSheetPopup').dialog({ 
      modal: true, 
      resizable: false, 
      title: 'Generate Term Sheet', 
      width: 375, 
      height: 425, 
      autoOpen: false, 
      buttons: { 
       "Generate": function() { 
        GenerateTermSheet(); 
       }, 
       "Cancel": function() { 
        $(this).dialog("close"); 
       } 
      } 
     }); 
+0

你在哪裏調用`GenerateTermSheet()`? – Dutchie432 2011-02-10 21:40:18

+0

已添加,但它的調用正確,因爲我可以在設置urlString後發出警報並且它可以正常工作。 – slandau 2011-02-10 21:43:36

+0

順便說一下......即使在沒有關閉標籤的情況下工作,也不是不關閉它們的理由......總是關閉標籤是一個好習慣。 – Mash 2011-02-10 21:48:21

回答

0

正如我在我的評論中提到,你永遠不會告訴JS時要執行的功能。看我的現場演示。似乎工作確定,如果我去掉ASP的東西。

http://jsfiddle.net/db4Uf/1/

這是重點線

//When an input in termSheetPopup is clicked, call GenerateTermSheet() 
$('#termSheetPopup input').click(function(){ 
    GenerateTermSheet(); 
}); 
+0

如果我這樣做對我不起作用=/ – slandau 2011-02-10 21:45:05

+0

...如果你做什麼? – Dutchie432 2011-02-10 21:45:27

0

試着改變選擇器:

$('#termSheetPopup input[type=checkbox][checked]') 
0

嘗試:checkbox:checked(注意額外的冒號)。

0
$(document).ready(function() { 
    $('#selecctall').click(function(event) { //on click 
     if(this.checked) { // check select status 
      $('.checkbox1').each(function() { //loop through each checkbox 
       this.checked = true; //select all checkboxes with class "checkbox1"    
     }); 
    } else { 
     $('.checkbox1').each(function() { //loop through each checkbox 
      this.checked = false; //deselect all checkboxes with class "checkbox1"      
     });   
    } 
}); 

});