Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从客户端获取文本框值并从中创建查询字符串?_Javascript_Jquery_Query String - Fatal编程技术网

Javascript 如何从客户端获取文本框值并从中创建查询字符串?

Javascript 如何从客户端获取文本框值并从中创建查询字符串?,javascript,jquery,query-string,Javascript,Jquery,Query String,我将jquery用于模态对话框。我想从一个页面打开模型对话框,并向模式对话框页面发送一些额外的查询字符串。大概是这样的: <asp:HyperLink ID="hypClientSearch" runat="server" NavigateUrl="~/SomePage.aspx?KeepThis=true&additionalQS='<%= txtBox.Text %>'&TB_iframe=true&height=650&width=800

我将jquery用于模态对话框。我想从一个页面打开模型对话框,并向模式对话框页面发送一些额外的查询字符串。大概是这样的:

 <asp:HyperLink ID="hypClientSearch" runat="server" NavigateUrl="~/SomePage.aspx?KeepThis=true&additionalQS='<%= txtBox.Text %>'&TB_iframe=true&height=650&width=800&modal=true" CssClass="thickbox" > 


这个例子不起作用。有人知道解决方案吗?

打开模式对话框时,在该对话框中尝试此操作(这是客户端javascript):


然后使用Javascript将附加信息插入对话框的正确位置,例如使用JQuery。

除了Helgi的答案之外。
如果要使用jQuery获取文本框的值(当需要使用其他选择器时,则使用id),可以使用:

var textBoxValue = $(textBoxSelector, window.opener.document).val();
编辑
哦,我刚刚注意到你在使用模态。然后在iFrame中打开页面,您可以使用以下方法从iFrame中获取值:

var textBoxValue = $(textBoxSelector, window.parent.document).val();
此外,如果需要在iFrame请求时将其发送到服务器,请尝试在单击时编辑链接的href属性:

$('#hypClientSearch').click( function() {
 var textBoxContent = $(textBoxSelector).val();
 $(this).attr('href', 'somepage.aspx?textbox='+textBoxContent+'&otherVarsForModal=foo');
 //we let the event bubble for the modal plugin, so ne returning false here
});
$('#hypClientSearch').click( function() {
 var textBoxContent = $(textBoxSelector).val();
 $(this).attr('href', 'somepage.aspx?textbox='+textBoxContent+'&otherVarsForModal=foo');
 //we let the event bubble for the modal plugin, so ne returning false here
});