[英]How to pass values from one page to another by onclick in javascript?
[英]how to pass values from one page to another page in javascript
嗨,我有一個用javascript創建的表,我需要知道的是如何使用javascript並單擊按鈕將第1或2行中的值傳遞到aspx頁面:這是我的javascript代碼:
newContent += Hesto.Html.StartTR(item.CommonCable, 'lineInfoRow');
newContent += Hesto.Html.CreateTD('<input type="button" value="Print" id="btnprint" onclick="Redirect()">',null);
newContent += Hesto.Html.CreateTD(item.CommonCable, null, null);
newContent += Hesto.Html.CreateTD(item.Wire, null, null);
newContent += Hesto.Html.CreateTD(item.WireLength * 1000, null, 'centerAlign');
newContent += Hesto.Html.CreateTD(item.TerminalA, null, (sideFlag == 1 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
newContent += Hesto.Html.CreateTD(item.SealA, null, (sideFlag == 1 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
newContent += Hesto.Html.CreateTD(item.TerminalB, null, (sideFlag == 2 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
newContent += Hesto.Html.CreateTD(item.SealB, null, (sideFlag == 2 ? 'highlightOneSide' : (sideFlag == 3 ? 'highlightTwoSides' : 'highlightNone')));
newContent = Hesto.Html.EndTR(newContent);
});
$('#AlternativeReworkCablesList').html(newContent);
}
這是我的重定向頁面:
function Redirect() {
window.open ("http://10.19.13.67/ReworkLabels/Default.aspx","my window");
return false;
}
您有幾種選擇:您可以將數據保存在cookie中以供以后重用,可以將數據作為一系列GET
變量傳遞到下一頁,或者可以使用AJAX加載下一頁,以便保留變量可用。
由於您使用的是ASP,因此可以執行以下操作:
function Redirect() {
window.open ("http://10.19.13.67/ReworkLabels/Default.aspx?myVariable=" + myVariable,"my window");
return false;
}
要發送大量數據,您可以嘗試以下操作:
textarea
/ text
字段(不必要) 請注意,javascript將以這種形式轉義數據。 要取消轉義,請使用unescape()
函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.