0

I have a jsp that contains a table with some information from db. I have the possibility to edit/delete/submit. If I click on submit button, I want to disable edit and delete buttons.

Do you have any suggestions on how can I do this?

My table looks like this:

<tr>
        <td><%=rs.getInt(1)%></td>
        <td><%=rs.getString(2)%></td>
        <td><%=rs.getString(3)%></td>
        <td> 
        <input type="image" src="../img/edit.gif" width="20" height="20" />
        </td>
        <td> 
        <input type="image" src="../img/delete.gif" width="20" height="20"  onclick="deleteRecord(<%=rs.getInt(1)%>);"/>
        </td>
        <td> 
        <input type="button" style="border:0;background:transparent;font-family:Trebuchet MS" value="Submit" onclick="submitPaper(<%=rs.getInt(1)%>);"/>
         </td>
        </tr>
user1391078
  • 53
  • 1
  • 2
  • 9

1 Answers1

0

I don't understand what do you mean by disable the buttons, when you use images. If your Submit button will update your data and redirect to a same page with the same table, then you should have an attribute in your bean (in your rs, for this case) that tells you the image shouldn't be showed or that it doesn't have any onclick attribute code. In this example, I'm using a 0-1 evaluation based value to add the onclick in your image:

<tr>
    <td><%=rs.getInt(1)%></td>
    <td><%=rs.getString(2)%></td>
    <td><%=rs.getString(3)%></td>
    <td> 
        <input type="image" src="../img/edit.gif" width="20" height="20" />
    </td>
    <td> 
        <input type="image" src="../img/delete.gif" width="20" height="20" 
        <% if (rs.getInt(5) == 0) { %>
            onclick="deleteRecord(<%=rs.getInt(1)%>);"
        <% } %>
        />
    </td>
    <td> 
        <input type="button" style="border:0;background:transparent;font-family:Trebuchet MS"
            value="Submit" onclick="submitPaper(<%=rs.getInt(1)%>);"/>
     </td>
</tr>

As a side note, when you program using JSPs, its bad idea to use scriptlets, there are new technologies that help you avoid this, like JSTL. See:

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332