将从弹出jsp中选择的值填充到当前jsp
我使用以下代码生成弹出
当前页面
<script LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=1,statusbar=0,menubar=0,resizable=1,width=250,height=800 left = 630,top = 502');");
}
</script>
<h:outputText value="Student Number : "></h:outputText>
<h:inputText id="stuNo" value="#{stuBean.stuNumber}" onfocus="javascript:popUp('OpenStudentList.jsp')" > </h:inputText>
Popup.jsp
<script LANGUAGE="JavaScript">
function setValue(stuNo){
window.opener.document.getElementById(stuNo).value;
window.close();
}
</script>
<h:dataTable id="dt" value="#{Student.openStuList}" var="openStuList" >
<h:column>
<f:facet name="header">
<h:outputText style=""value="Student Number" />
</f:facet>
<h:form>
<h:commandLink style="" value="#{openStuList.stuNumber}" onclick="javascript:setValue(#{openStuList.stuNumber})" ></h:commandLink></h:form>
</h:column>
</h:dataTable>
我的弹出 jsp 有一个数据表,其中包含一个字段学生编号,每个字段都是一个链接。当我单击链接时..我希望将值填充到当前 jsp 的文本框中。我尝试过使用 setValue() javascript 函数,但不起作用 需要这方面的建议
I'm using the following code to generate a popup
Current Page
<script LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=1,statusbar=0,menubar=0,resizable=1,width=250,height=800 left = 630,top = 502');");
}
</script>
<h:outputText value="Student Number : "></h:outputText>
<h:inputText id="stuNo" value="#{stuBean.stuNumber}" onfocus="javascript:popUp('OpenStudentList.jsp')" > </h:inputText>
Popup.jsp
<script LANGUAGE="JavaScript">
function setValue(stuNo){
window.opener.document.getElementById(stuNo).value;
window.close();
}
</script>
<h:dataTable id="dt" value="#{Student.openStuList}" var="openStuList" >
<h:column>
<f:facet name="header">
<h:outputText style=""value="Student Number" />
</f:facet>
<h:form>
<h:commandLink style="" value="#{openStuList.stuNumber}" onclick="javascript:setValue(#{openStuList.stuNumber})" ></h:commandLink></h:form>
</h:column>
</h:dataTable>
my popup jsp has a datable which contains a field student Number each of which is a link. When i click on the link..I want the value to be populated in the current jsp's textbox. I've tried using the setValue() javascript function which didn't work
Need suggestions on this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一个想法。在当前页面的
input
上添加一个类似于id="student_number
的 ID,然后在弹出窗口中的链接上让它引用 opener 窗口来更新文本框,类似于:yourWindowObject.opener.document.getElementById('student_number').value = 'some value';
为此,您可能需要找到一种方法来引用创建的弹出对象并似乎您正在使用当前时间的 eval 创建保存弹出窗口的变量,这可能很难轻松引用它。
Just an idea. Add an ID on the current page's
input
with something likeid="student_number
and then on the link in your pop-up have it refer to the opener window to update the textbox, something like:yourWindowObject.opener.document.getElementById('student_number').value = 'some value';
To do this you probably need to find a way to reference the created pop-up object and get its opener. Seems you are creating the variable that holds the pop-up using eval with current time which may be hard to refer to it easily.