Struts 1 action not getting called within javascript function in jsp -
i using display tag display list onto table. trying have button delete row based on row id. id getting passed javascript function action not getting called. know value getting passed because when tested using alert output id within function, did.
i ran firebug , saying form undefined
what have
display tag table:
<form action="" method="post" id="mainform" name="myformbean"> <display:table requesturicontext="true" requesturi="/unavailability/loadunavailability.action?method=loadform" uid="mylist" name="requestscope.unavaillist" class="simple" pagesize="10" defaultsort="2" sort="list" cellspacing="0" excludedparams="*"> <display:column property="startdate" title="start date" width="18%" decorator="com.mhngs.util.displaytagdatewrapper" sortable="true" headerclass="sortable"/> <display:column property="enddate" title="end date" width="18%" decorator="com.mhngs.util.displaytagdatewrapper" sortable="true" headerclass="sortable" /> <display:column property="reason" title="comments" width="30%" sortable="true" headerclass="sortable" /> <display:column media="html" width="10%"> <a href="#" onclick="javascript:deleteentry('<c:out value="${mylist.rowid}"/>')">delete</a> </display:column> </display:table> <input type="hidden" name="rowid" id="rowid" /> </form>
javascript:
function deleteentry(rowid){ document.getelementbyid('rowid').value=rowid; document.forms[0].action='/app/protected/mflc/unavailability/delcounselorentry.action?method=deletecounselorunavailability'; document.forms['myform'].submit; //correction }
struts form bean:
<form-bean name="myformbean" type="org.apache.struts.action.dynaactionform"> <form-property name="mylist" type="java.util.list"/> </form-bean>
struts delete mapping:
<action path="/unavailability/delcounselorentry" type="com.action.myaction" scope="request" parameter="method" name="myformbean"> <forward name="success" path="/unavailability/mydeletecomfirmationpage.actioncontent" /> </action>
any appreciated, thanks
i found reason why form undefined
i had @ first points first form:
document.forms[0]; //first <form> element
but if have name form, need point form this:
document.forms['myform']; //points <form name="name_of_form">
Comments
Post a Comment