如何在javascript中将值从一个页面传递到另一个页面
您好,我有一个用javascript创建的表,我需要知道的是如何使用javascript通过单击按钮将第1行或第2行中的值传递到aspx页面: 以下是我的javascript代码:如何在javascript中将值从一个页面传递到另一个页面,javascript,Javascript,您好,我有一个用javascript创建的表,我需要知道的是如何使用javascript通过单击按钮将第1行或第2行中的值传递到aspx页面: 以下是我的javascript代码: newContent += Hesto.Html.StartTR(item.CommonCable, 'lineInfoRow'); newContent += Hesto.Html.CreateTD('<input type="button" value="Print" id="btn
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);
}
您有几个选项:您可以将数据保存在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将以这种形式转义数据。要取消它,请使用函数。它是否在同一个域上?可能重复@Jamie?我不同意,因为可能的解决方案不一定是查询string@aduch:不一定,但这是一种可能的解决方案。@CBroe同意注释
的这一部分,因为您使用的是ASP,您可以这样做:
他使用的东西不是必需的。您建议使用简单的查询字符串。它在web中工作,但不仅仅在asp中工作
function Redirect() {
window.open ("http://10.19.13.67/ReworkLabels/Default.aspx?myVariable=" + myVariable,"my window");
return false;
}