2016-09-27 92 views
-2

,當我使用錨標籤傳遞的查詢字符串我讓我的url,但問題產生的查詢字符串是有processorId = 51重複twise 我的字符串來了一樣, MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?processorId = 51 & bankId = 51 & bankId = 2866錯誤使用錨標記

,但我預計

MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?processorId = 51 & bankId = 2866

請給我這個

+ "<li><a target='_blank' href='/MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?processorId=' >View By Date</a></li>" 

+ "<li><a target='_blank' href='/MonthlySettlementAlgorithm/MonthlySettlementResultViewByBank?processorId=' >View By Bank</a></li>" 

    Jquery Code 

     $('.dropdown-menu.features li a').each(function() { 
      if ($(this).attr('href')) 
      { 
       $(this).attr('href', $(this).attr('href') + selectedProcessorIds +'&bankId='+ selectedBankIds); 
      } 
     }); 
+0

設置'HREF液='/ MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate''最初,當你建立了'在JS了'標籤。 – Shyju

+0

我已經試過這一行,但我沒有得到確切的 –

回答

0

解決方案最終我得到這個

$('.dropdown-menu.features li a').each(function() { 

    var href = $(this).attr('href'); 
    if (href) { 
     var requiredArray = href.split('?'); 

     if (requiredArray.length > 1) { 
      var tempProcString = "processorId=" + selectedProcessorIds; 
      var tempBankString = "&bankId=" + selectedBankIds; 
      var tempDate = "&snapshotDate=" + $('#txtDate_FirstDateValue').val(); 
      requiredArray[1] = tempProcString + tempBankString + tempDate; 
      console.log(requiredArray[1]); 
     } 

     //finally updating href 
     $(this).attr('href', requiredArray.join('?')); 
    } 
});