jquery - How to add new row in jsp with incremented value from server -


this code add row in div. on click on #add fetch new row , append .panel-body code working not able set incremented values in newly added row.

 $(document).ready(function() {         $(document).on('click', '#add', function(event) {         event.preventdefault();                 $.ajax({                 type: "post",                         url: "getnewrow",                         data: 1,                         datatype: "html",                         success: function(data) {                         $(".panel-body").append(data);                         }                 });         }); 

in struts.xml

<action name="getnewrow" class="iland.expense.expenxeaction" method="getnewrow">             <result name="success">/pages/expense/newrow.jsp</result>             <result name="input">/pages/expense/newrow.jsp</result>             <result name="login">/pages/login.jsp</result>                         <result name="unauthorized">/pages/unautho.jsp</result>         </action> 

in newrow.jsp

<%@taglib uri="/struts-tags" prefix="s"%> <div class="row" id="<s:property value="id"/>">     <div class="col-xs-1"></div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>expensed type</label>         <s:select name="expenselist[0].param"                    list="'advertisement','food'"/>     </div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>amount</label>         <s:textfield name="expenselist[0].value" value="%{expenselist[0].value}"/>     </div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>date</label>         <s:textfield name="expenselist[0].dt" value="%{expenselist[0].dt}"/>     </div>     <div class="form-group col-xs-1 col-sm-1 col-lg-1 cl">         <label ></label>         <img src="images/delete.png"/>     </div>  </div> 

here <s:property value="id"/> incremented value want assing in newrow.jsp in , , want set expenselist[0] expenselist[1]

how this.

i solved problem. in action incrementing value 1 , made change in newrow.jsp below

<%@taglib uri="/struts-tags" prefix="s"%> <div class="row" id="<s:property value="rowid"/>">     <div class="col-xs-1"></div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>expensed type</label>         <s:select name="expenselist[%{rowid}].param"                    list="'advertisement','food'"/>     </div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>amount</label>         <s:textfield name="expenselist[%{rowid}].value" value="%{expenselist[%{rowid}].value}"/>     </div>     <div class="form-group col-xs-1 col-sm-6 col-lg-3">         <label>date</label>         <s:textfield name="expenselist[%{rowid}].dt" value="%{expenselist[%{rowid}].dt}"/>     </div>     <div class="form-group col-xs-1 col-sm-1 col-lg-1 cl">         <label ></label>         <img src="images/delete.png"/>     </div> 

%{rowid} solved problem.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -