2013-10-08 63 views
0

在下面的代碼中有兩個函數:OppSelect()函數調用另一個函數,即exOpp()。現在,如何獲得OppSelect()的「結果」值爲「exOpp()」函數並追加到url?請幫忙。如何將字符串結果追加到javascript函數中的servlet URL

JS:

function exOpp() { 

    alert("inside"); 

    document.forms[0].action = "/Mgmt/ExportOpp?loadData=xls&customerprofile=" + $customerIDH + "&role=" + $roleIDH + "&targetDate=" + $targetDateH + "&actualDate=" + $actualDateH; 
    document.forms[0].submit(); 
} 

function OppSelect() { 

    var menu = document.getElementById('selectedServersID').length; 
    alert(menu); 
    var result = ""; 
    for (var i = 0; i < menu; i++) { 

     var selectedcol = document.getElementById('selectedServersID')[i].value; 
     //var selectedcol = document.getElementById('selectedServersID')[i].innerHTML; 
     // alert(selectedcol); 

     if (i > 0) { 
      result += ','; 
     } 
     result += selectedcol; 
    } 

    alert(result); 
    exOpp(); 
} 

回答

0

喜ü可以把它作爲參數來exOpp(result);

function exOpp(data) { 

var urldata = data; 

       document.forms[0].action = "/Mgmt/ExportOpp?loadData=xls&customerprofile="+$customerIDH+"&role="+$roleIDH+"&targetDate="+$targetDateH+"&actualDate="+$actualDateH; 
       document.forms[0].submit(); 

     } 

現在添加urldata到urstring爲你所需要..

+0

嗨,感謝您的回答..如何將數據追加到document.forms [0] .action =「/ Mgmt/ExportOpp?loadData = xls&customerprofile =」+ $ customerIDH +「&role =」+ $ roleIDH +「&targetDate =」+ $ targetDateH +「&act ualDate =「+ $ actualDateH; ? – 123HIS

+0

因爲你已經添加了「&role =」+ $ roleIDH +你可以像這樣添加「&role =」+ urldata +到你需要傳遞的值中的任何一個參數。 – codebreaker

相關問題