将3个文本框值传递给ASPX中的javascript函数

时间:2017-11-16 03:46:42

标签: javascript c# asp.net

我想将三个文本框值传递给javascript函数。然而它不工作。非常感谢任何帮助。这是我尝试过的。

Array

2 个答案:

答案 0 :(得分:1)

在第一页按钮上单击代码

<script>
var value1="value1";
var value2="value2";
var queryString = "?para1=" + value1 + "&para2=" + value2;
window.location.href = "page2.html" + queryString;
</script> 

在第二页

<script>

var queryString = decodeURIComponent(window.location.search);
queryString = queryString.substring(1);
var queries = queryString.split("&");
for (var i = 0; i < queries.length; i++)
{
  document.write(queries[i] + "<br>");
}

</script> 

希望这会对你有所帮助

答案 1 :(得分:0)

     <asp:Button ID="PrintCheck" runat="server" target="_blank" 
     OnClientClick='openWindow()'   Text="Print Cheque" CssClass="btn5" 
     ForeColor="White" Width="120px" ToolTip="Print Cheque" />

     <script type="text/javascript">
     function openWindow() {
     var payname = document.getElementById('<%=txtbox_chprovider.ClientID 
      %>').value;
      var chdate = document.getElementById('<%=txtbox_chqdate.ClientID 
      %>').value;
      var chamount = document.getElementById('<%=txt_chamount.ClientID 
      %>').value;
    window.open("Product.aspx?payname=" + payname + "&chdate= " + chdate + " 
    &chamount= " + chamount + "", "_blank", 
    "toolbar=yes,scrollbars=yes,top=10,left=10", "true");
          };
</script>