0

` User ID Leave Type Start Date End Date Status Approve/Reject

    </tr>
 <c:forEach var="roww" items="${resultt.rows}">
  <tr>
   <td><c:out value="${roww.uid}"/></td>
   <td><c:out value="${roww.type}"/></td>
   <td><c:out value="${roww.stdt}"/></td>
   <td><c:out value="${roww.enddt}"/></td>
   <td><input type="button" value="Approve" name="app" onclick="approval();" />
       <input type="button" value="Reject" name="rej" onclick="rejection();" />  
       `

I want to call a function approval() when the Approve button is clicked. The Function needs to access data values from the row in which it is clicked. I also need to change the value of Status column in the database for that particular row.

I'm using JSP and MySQL database

user3270763
  • 125
  • 1
  • 3
  • 13
  • Answer might depend on a) what language you are using to generate this HTML and b) what database you are using. – Scott Hunter Mar 11 '14 at 10:39
  • My suggestion would be to use jQuery and any of the multiple data table plugins it has, then you'd be able to select it with ease and have several features like loading/sorting/searching built in – user3036342 Mar 11 '14 at 10:40

1 Answers1

1

adding this as a parameter in approval should give you the dom element clicked you can then navigate from there i.e approval(this);

what's "this" in javascript onclick?

i would recommend using something like jQuery to attach the event listener thou.

jQuery API click

Community
  • 1
  • 1
PB1
  • 117
  • 4
  • I tried using 'this' as a parameter and then using it with functions to calculate row or cell index, so that I know which entry to edit in the database. This is not working out.. – user3270763 Mar 12 '14 at 09:34
  • if you just need a unique reference to the data add '${roww.uid}' as a parameter i.e approval(this,'${roww.uid}'); – PB1 Mar 12 '14 at 11:05
  • I passed '${roww.uid}' as a parameter to a function. But its value fails to be even printed through the function. Do I need to apply some sort of a special function to be able to display its value? – user3270763 Mar 12 '14 at 20:37