Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在Struts 2中单击按钮时弹出_Jquery_Jsp_Struts2 - Fatal编程技术网

Jquery 在Struts 2中单击按钮时弹出

Jquery 在Struts 2中单击按钮时弹出,jquery,jsp,struts2,Jquery,Jsp,Struts2,我的JSP中有以下代码 function doContractAction(actionUrl) { var strActionUrl = actionUrl; if(strActionUrl !=null) { document.forms[0].action = actionUrl; document.forms[0].submit(); } return false;

我的JSP中有以下代码

function doContractAction(actionUrl) {

        var strActionUrl = actionUrl;
        if(strActionUrl !=null) {
            document.forms[0].action = actionUrl;
            document.forms[0].submit();
            }
        return false;
    }

<div id="content">
    <div id="report">
    <s:form name="openControl" id="myActionForm" theme="simple" action="ShowAlertReports" method="post">
        <div id="accordion">

            <s:iterator id="alertCat" value="alerts" status="status" >

                <h2  style="font-size:1.1em; padding-top:0px;padding-left:1px;padding-bottom:-5px; font-weight:bold;">
                <p align="left"><s:property value="%{key}"/></p>
                </h2>
                <br>
                <div>

                    <table id="${status.index}" class="grid one-em-below constant-left-width" cellspacing="0" d="ad-hoc-reports">
                        <thead class="nosort">
                            <tr>
                                <th scope="col" class="sortAsc" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Alert Name </a></th>
                                <th scope="col" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Customer Name</a></th>
                                <th scope="col" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Date Opened</a></th>
                                <th scope="col">Action</th>

                            </tr>
                        </thead >
                        <tbody style="font-size:12px;">
                            <s:iterator id="alertsubcat" value="%{value}">
                                <tr>
                                    <td>
                                        <s:property value="name"/>
                                    </td>
                                    <td>
                                        <s:property value="customerName"/>
                                    </td>
                                    <td style="font-size:11px;">
                                        <s:if test="%{display=='OK'}">
                                        <input type="button" value='<s:property value="%{display}" />'
                                            onclick='return closeInfoAlert("<s:property value="%{alertsNotificationId}" />");' />
                                        </s:if>

                                        <s:else>
                                            <input type="button" value='<s:property value="%{display}" />' 
                                            onclick='return doContractAction("<s:property value="%{url}" />");' />
                                        </s:else>
                                    </td>

                                </tr>
                            </s:iterator>

                        </tbody>
                    </table>
                    <br>
                </div>
            </s:iterator>
        </div>
    <s:hidden name="description" id="description" value=""/>
    </s:form>
<br>
</div>
</div>
函数doContractAction(actionUrl){
var strActionUrl=actionUrl;
if(strActionUrl!=null){
document.forms[0]。action=actionUrl;
document.forms[0]。提交();
}
返回false;
}


警报名称 客户名称 开放日期 行动

现在

可以有值了

  • 警报1、警报2、警报3等
  • 我的要求来自代码

    <s:else>
        <input type="button" value='<s:property value="%{display}" />' 
        onclick='return doContractAction("<s:property value="%{url}" />");' />
    </s:else>
    
    
    
    我需要传递值=“%{key},该值将在函数doContractAction 我可以检查键中的值,它是否等于警报1或警报2。 我打开一个弹出窗口


    如何实现这一点?

    您可以使用struts2计数器为循环中的每个元素提供唯一的id,我已经提供了一个链接来引用struts2中的计数器

    现在为
    按钮
    提供唯一的id,现在您将获得如下所示的元素

    <p id="p-0" align="left"> <input id="input-0" type="button"> 
    <p id="p-1" align="left"> <input id="input-1" type="button"> 
    ...
    <p id="p-n" align="left"> <input id="input-n" type="button"> 
    

    ...

    现在,您可以使用
    this.id来传递按钮的id,您可以参考
    

    现在您可以拆分
    input id
    和construct
    p-id
    。一旦获得
    p-id
    。现在您可以使用

    url是在函数getURL的Java类中定义的,即公共字符串getURL(){//some code return url;}不清楚您想要实现什么:/