将从弹出jsp中选择的值填充到当前jsp

发布于 2024-11-07 01:26:12 字数 1502 浏览 0 评论 0原文

我使用以下代码生成弹出

当前页面

        <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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁以何悠 2024-11-14 01:26:12

只是一个想法。在当前页面的 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 like id="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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文