Reputation: 4141
in my jsp i have a table constructed dynamically like the following:
' retour.append("");
try {
s= HibernateUtil.currentSession(); tx=s.beginTransaction(); Query query = s.createQuery(HQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();)
{
if(it.hasNext()){
Dailytimesheet object=(Dailytimesheet)it.next();
retour.append("<td>" +object.getActivity() +"</td>");
retour.append("<td>" +object.getProjectCode() + "</td>");
retour.append("<td>" +object.getWAName() + "</td>");
retour.append("<td>" +object.getTaskCode() +"</td>");
retour.append("<td>" +object.getTimeFrom() +"</td>");
retour.append("<td>" +object.getTimeSpent() + "</td>");
retour.append("<td>" +object.getPercentTaskComplete() + "</td>");
if (droitdaccess)
{
retour.append(""); retour.append(""); retour.append("");
retour.append("<td bordercolor=#FFFFFF>");
retour.append("<input type=\"hidden\" id=\"id_"+nomTab+"_"+compteur+"\" value=\""+object.getIdDailyTimeSheet()+"\"/>");
retour.append("<img src=\"icon_delete.gif\" onClick=\"deletearowById('id_"+nomTab+"_"+compteur+"')\" style=\"cursor:pointer\" name=\"action\" value=\"deleting\" />");
retour.append("</td>");
}
}
compteur++;
retour.append("</tr>");
}
retour.append ("</table>");'
next to the table i want to display a button named send in order to send the table content. I do not really want to dispaly this button where the table is empty.
So at least if the table is populated by only one record i want that button being displayed. How should i deal in this case.
Thanks.
Upvotes: 0
Views: 2022
Reputation: 19353
Just like you created an hidden field i each row, you can create a button once you close your table tag:
retour.append("<input type='button' value='Send' onclick='fun()'/>");
But you will have to put a condition to check if your query returned any rows. If it retured, use the above statement to append the button, else ignore it.
Upvotes: 1