1
내가 실행하고자하는onclick 후에 JSP와 JAVASCRIPT를 모두 실행할 수 있습니까? 여기
<CODE>
<table id = "add_degree">
<tbody>
<tr>
<td>
<%rs2 = st.executeQuery("Select * from degrees"); %>
<select name = "courses">
<%while(rs2.next()) {%>
<option value = "<%=rs2.getString(1)%>"><%=rs2.getString(2)%></option>
<%} %>
</select>
</td>
<td>
<input type = "text" name = "ratings" class = "span1">
</td>
<td>
<a href = "">Delete Course</a>
</td>
</tr>
</tbody>
</table>
여기 온 클릭 이벤트가 유사한 셀 블록으로 기존 테이블에 새 행을 추가 온 클릭 이벤트 이후 자바 스크립트와 JSP 모두. 데이터베이스에 행 데이터를 입력하는 JSP 코드가 있습니다. JSP와 자바 스크립트 코드를 동시에 실행하여 새 행이 있고 이전에 입력 한 데이터가 데이터베이스에 입력 될 수 있습니까?
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "button":
newcell.childNodes[0].value = "Delete Course";
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}
자바 스크립트 onclick 이벤트 처리기에서 AJAX 요청을 서버로 보냅니다. –