简体   繁体   English

使用javascript将值传递给字段

[英]passing values to fields using javascript

I'm currently building an app where i need somewhat of a lookup control. 我目前正在构建需要一些查找控件的应用程序。 How this would work is that there is a texbox with a lookup button on a form. 如何工作是在表单上有一个带有查找按钮的texbox。 The user can either type in a value for the textbox or can choose the lookup button. 用户可以输入文本框的值,也可以选择查找按钮。 When the user presses the lookup button a javascript window with a gridview and a list of columns appears. 当用户按下查找按钮时,将显示一个带有Gridview和列列表的JavaScript窗口。 What i'd like to do is allow the lookup window to pass back the selected gridview value to the textbox on the first page and disable the textbox. 我想做的是允许查找窗口将选定的gridview值传递回第一页上的文本框,并禁用该文本框。

Can anyone help me with an example or so of how to go about doing this? 谁能帮我举一个例子,说明如何做到这一点?

Thanks in advance 提前致谢

If you opening a window with window.open() you could just access opener object which points to the opening window and access it's dom/jhavascipt functions. 如果使用window.open()打开一个窗口,则可以访问指向打开窗口的打开器对象并访问它的dom / jhavascipt函数。 // in window var retVal = ... opener.MyFunction(retVal) this.close() //在窗口中var retVal = ... opener.MyFunction(retVal)this.close()

// in main page
var valFromWindow = null;
function MyFunction(val)
{
   valFromWindow = val;
}

If you opening a window by making a hidden div visible, then you can just use any javascript you have in current window. 如果通过使隐藏的div可见来打开窗口,则可以使用当前窗口中的任何JavaScript。

If you opening a window with window.showModalDialog you can pass back value using returnValue property. 如果使用window.showModalDialog打开窗口,则可以使用returnValue属性传回值。 window.returnValue = "myretval" // in modal dialog window.returnValue =“ myretval” //在模式对话框中

var retval = window.showModalDialog(...) // in main window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM