2015-10-12 17 views
0

目前我有一個操作鏈接,將數據提交給一個操作。它還調用一個函數,它根據視圖上的數據填充一些JQuery參數。我想將這些JQuery值附加到操作鏈接,以便它們可以同時提交。如何附加JQuery以在Action Link上路由值?

查看:

<div class="AltFunctions"> 
        <ul> 
         <li> 
          @Html.ActionLink("fd", "ExportClaimBySupplier", "Search", new {ClientID = Model.inputParameters[0], SupplierID = Model.inputParameters[1], JsonReviewPeriod = Json.Encode(Model.inputReviewPeriodIDs), GroupID = Model.inputParameters[2], AmountFrom = JQueryValue, AmountTo = JQueryValue, AllDDValues = JQueryValue}, new { @id = "altExportButton", @class = "AltButton", Title = " Export data to excel" }) 
         </li> 
         <li> 
          <a href="#ClaimsBySupplierModal" data-target="#ClaimsBySupplierModal" data-toggle="modal" class="AltButton" id="altInfoButton" title="Information on the Supplier report">Info</a> 
         </li> 
        </ul> 
       </div> 

JQuery的:

<script> 
    $('#altExportButton').on('click', function() { 
      var AmountFrom = $('#txtAmountFrom').val(); 
      var AmountTo = $('#txtAmountTo').val(); 
      var AllDDValues; 
      var count = 1; 
      $('.ExportValues').each(function() { 

       if (count == 1) { 
        AllDDValues = this.value; 
        count = 2; 
       } 
       else if(count == 2 && AllDDValues != "") { 
        AllDDValues = AllDDValues + ", " + this.value; 
       } 
      });    
     }); 

    </script> 

我需要AmountFrom,AmountTo和AllDDValues追加到操作鏈接。

回答

1

服務器完成後,動作鏈接變成<a>。 jquery會在客戶端發生變化後變成<a>

然後,你可以做這樣的事情:

$('#altExportButton').attr('href', function(index, attr) { 
return attr + '&AllDDValues=' + AllDDValues + '&AmountTo =' + AmountTo +'&AmountFrom=' + AmountFrom; 
}); 

這應該追加你要找哪個則應將它們發佈到單擊服務器的URL的值。

+0

謝謝!有效 –

相關問題