jquery - pop-up on click of a button in Struts 2 -
i have next code in jsp
function docontractaction(actionurl) { var stractionurl = actionurl; if(stractionurl !=null) { document.forms[0].action = actionurl; document.forms[0].submit(); } homecoming 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>
now <p align="left"><s:property value="%{key}"/></p>
can have values
my requirement code
<s:else> <input type="button" value='<s:property value="%{display}" />' onclick='return docontractaction("<s:property value="%{url}" />");' /> </s:else>
i need pass value="%{key} checked in function docontractaction , can check value in key , if equals alert1 or alert 2 . open pop-up window
how accomplish ?
you can utilize struts2 counter give unique id's each element in loop,i have given link refer counter in struts2 here
now give unique id's button
, <p>
, have elements given below
<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">
now can pass id of button using this.id
can refer here
now can split input-id
, counstruct p-id
. 1 time p-id
. can value of p
using getelementbyid()
jquery jsp struts2
No comments:
Post a Comment