如何获取重复控件中第 n 个编辑框的值? [英] How do I get the value of nth Edit box in a repeat control?

查看:24
本文介绍了如何获取重复控件中第 n 个编辑框的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在重复控件中有一个 EditBox 控件.其迭代公式为:

I have an EditBox control in a repeat control. Its iteration formula is:

return 5;

成功显示4个编辑框(起始索引设置为1).

It is successfully displaying 4 edit boxes (the starting index is set to 1).

在SSJS中,如何获取第n个编辑框的值?

In SSJS, how can I get the value of the nth Edit Box?

推荐答案

您可以在编辑框的 onchange 事件上设置 sessionScope 变量(或任何范围变量),然后在您的 SSJS 中引用 sessionScope 变量.这是一些示例代码,底部仅显示页面上的 sessionScope 变量.

You could set a sessionScope variable (or any scope variable) on the onchange event of the edit box and then in your SSJS reference the sessionScope variable. Here is some sample code, the bottom bit just shows your sessionScope variables on the page.

<?xml version="1.0" encoding="UTF-8"?>

<xp:repeat id="repeat1" rows="30" value="#{javascript:5}"
    indexVar="rptIndex">

    <xp:inputText id="inputText1">

    <xp:eventHandler event="onchange" submit="true" refreshMode="complete">
        <xp:this.action>
            <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:sessionScope['text'+rptIndex] = getComponent("inputText1").getValue()}]]></xp:this.script>
            </xp:executeScript>
        </xp:this.action></xp:eventHandler></xp:inputText>

</xp:repeat>



<xp:table styleClass="debug">
<xp:tr>
<th>Variable Name</th>
<th>Variable Content</th>
</xp:tr>
<xp:repeat id="varRepeat" rows="30" value="#{javascript:sessionScope.keySet();}" var="scopeData">
<xp:tr>
<xp:td>
<xp:text escape="true" id="varName" value="#{javascript:scopeData}" />
</xp:td>
<xp:td>
<xp:text escape="true" id="varValue" value="#{javascript:sessionScope.get(scopeData)}" />
</xp:td>
</xp:tr>
</xp:repeat>
</xp:table> 
</xp:view>

这篇关于如何获取重复控件中第 n 个编辑框的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆