0
와 체크 박스 marqued HTML 테이블의 한 행 삭제 :나는 데이터베이스 에서처럼 동적으로 내 HTML 테이블을 구축 자바 스크립트
for (i = 0; i < nomCols.length; i++) {
retour.append(("<td bgcolor=#0066CC>") + nomCols[i] + "</td>");
}
retour.append("</tr>");
retour.append("<tr>");
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><input type=checkbox name=cb id=cb /> </td>");
retour.append("<td>" + object.getTrackingDate() + "</td>");
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.getTimeSpent() + "</td>");
retour.append("<td>" + object.getPercentTaskComplete() + "</td>");
}
retour.append("</tr>");
}
retour.append("</table>");
tx.commit();
} catch (HibernateException e) {
retour.append("</table><H1>ERREUR:</H1>" + e.getMessage());
e.printStackTrace();
}
return retour;
}
그래서 난 모든 확인란이 동일한 ID를 갖는하고자합니다. 내 테이블 마녀에서 한 행을 삭제하려고 할 때 확인란을 선택했는데 문제가 발견되었습니다. 이 같은 간단한 자바 스크립트를 사용하여 스피 :
function DeleteARow() {
//var Rows = document.getElementById('sheet').getElementsByTagName('tr');
//var RowsCount = Rows.length;
//alert('Your table has ' + RowsCount + ' rows.');
if (document.getElementById('cb').checked == true) {
document.getElementById('cb').parentNode('td').parentNode('tr').remove();
}
}
그것은 approperly 만 첫 번째 행 작업 ID 'CB'를 가지고 있지 않습니다.
많은 도움에 감사드립니다.
'$ ('. 인증 기관은 : 선택')에 가장 가까운 ('TR')) (제거;': –
@Nick 좋은 캐치, 감사 – Matt
어떻게 할 수.. 나는 class = "cb"라고 선언한다. 그리고 어디에서? – kawtousse