2017-04-26 36 views
-1

我想在這裏顯示數據如何在html中使用jQuery將值從一個頁面發送到另一個頁面

請幫忙。

$(function() { 
    var RETAIL_CRM = []; 
var dmJSON = "https://cordova.eu-gb.mybluemix.net/CRM.jsp"; 
$.getJSON(dmJSON, function(data) { 
    $.each(data.RETAIL_CRM, function(i, f) { 

     var tblRow = "<tr>" + "<td>" + "<a href=Details.html?value="+f.S_NO+"&value1="+f.STATUS+"&value2="+f.NAME+">" + f.S_NO +"</td>" + "</a>" + "<td>"+ f.NAME+ "</td>"+ "<td>" + f.STATUS + "</td>" + "</tr>";  
        $(tblRow).appendTo("#list"); 


}); 

     document.getElementById("crm_serialnumber").value = value; 
     document.getElementById("crm_name").value = value1; 
     document.getElementById("crm_status").value = value2; 


}); 
}); 

home.html的

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script> 
我在這裏印製的json谷SR_NO名稱和狀態,並使用上S.NO href標記

假設我在KMP體檢單擊它,然後應轉到下一頁(Details.html)

(附圖img2)並在此頁面上打印相同的SNO,名稱和狀態。

image1

Details.html(第二頁)我不是在這裏Ø打印我的價值觀。

感謝

image2

回答

0

您可以在一個頁面值發送到另一個使用查詢字符串

請參閱該代碼

// Convert query string into Single Search Paramerter 
    function getParameterByName(name) { 
     name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 
     var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 
     results = regex.exec(location.search); 
     return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 
    } 

    // To get the parameter 
    var userid = getParameterByName("UserId"); 

    // To send parameter to another page 
    window.location.href="xyz.html?UserId="+parameter ; 
相關問題