通过单击一个按钮调用另外两个按钮 [英] by clicking on one button invoke two other buttons

查看:31
本文介绍了通过单击一个按钮调用另外两个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过点击一个按钮来激活"另外两个按钮的点击.我已经把这个 ccjs 放在了 onclick 事件中:

I would like by clicking on a button to "activate" the clicking of 2 other buttons. I've put this ccjs in the onclick event:

document.getElementById("#{id:button28}").click();document.getElementById("#{id:button29}").click();

但是只有按钮 28 被点击了!然后我尝试将这部分代码放在 onclick 事件下,将第二部分放在 onmousedown 事件下.然后我必须在他真正完成工作之前点击这个按钮 2 次.

But then only button 28 gets clicked ! Then I tried putting this part1 of the code under the onclick event and part2 under the onmousedown event. Then I have to click 2 times this button before he actually does the job.

目前的代码:

<xp:button value="Save" id="button26">
<xp:eventHandler event="onclick" submit="false">
    <xp:this.script>
        <xp:executeClientScript>
    <xp:this.script><![CDATA[document.getElementById("#{id:button29}").click();
    ></xp:this.script>
        </xp:executeClientScript>
    </xp:this.script></xp:eventHandler></xp:button><xp:button id="button29" value="button29">
    <xp:eventHandler
    event="onclick" submit="true" refreshMode="partial"
    id="eventHandler21" refreshId="outsidePanel5">
        <xp:this.action>
            <xp:actionGroup>
                <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:sessionScope.put("test","");// and some more code}]]>
                </xp:this.script>
                </xp:executeScript>
            </xp:actionGroup>
        </xp:this.action>
    <xp:this.onComplete><![CDATA[document.getElementById("#{id:button28}").click();]]></xp:this.onComplete>
    </xp:eventHandler></xp:button><xp:button value="button28" id="button28">
    <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="outsideMogelijkheid">
        <xp:this.action>
            <xp:executeScript
                    script="#{javascript://some code}">
            </xp:executeScript>
        </xp:this.action>
    </xp:eventHandler></xp:button>

推荐答案

如果这些按钮执行 SSJS 代码你需要添加代码点击第二个按钮第一个按钮的 onComplete 事件.

If these buttons execute SSJS code you need to add the code to click on the second button in the onComplete event of the first button.

http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=0574D334CB03EACF852578CB00667F54

添加onComplete 的工作示例并不是它仅适用于部分刷新

Addition Working example of onComplete not that it only works with partial refresh

<xp:button value="Save" id="button26">
<xp:eventHandler event="onclick" submit="false">
    <xp:this.script><![CDATA[document.getElementById("#{id:button29}").click()]]>
</xp:this.script>
    </xp:eventHandler></xp:button>
<xp:button id="button29" value="button29">

<xp:eventHandler event="onclick" submit="true"
    refreshMode="partial" refreshId="computedField1">

    <xp:this.action><![CDATA[#{javascript:viewScope.test="Almost Done"}]]>
</xp:this.action>
    <xp:this.onComplete>
<![CDATA[document.getElementById("#{id:button28}").click();]]>
</xp:this.onComplete>
    <xp:this.onError><![CDATA[alert("error")]]></xp:this.onError>
</xp:eventHandler></xp:button>

<xp:button value="button28" id="button28">
    <xp:eventHandler event="onclick" submit="true" 
refreshMode="partial" refreshId="computedField1">

        <xp:this.script><![CDATA[alert("Button 28")]]></xp:this.script>
        <xp:this.action>
            <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:viewScope.test="Done"}]]>
</xp:this.script>
            </xp:executeScript>
        </xp:this.action></xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:text escape="true" id="computedField1" value="#{viewScope.test}"></xp:text>

这篇关于通过单击一个按钮调用另外两个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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