想請教各位大大
我有一個表格,checkbox,value(預設0),item
我希望使用者checkbox按下去後,value自動重0變1
但一值變不過去....
想請教各位到底是錯在哪?
<div class="container">
<table ><tbody id="myTable">
<%
String sql = "select * from send";
pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
pstmt.setQueryTimeout(60);
while(rs.next()){
String name = rs.getString("name");
String c_id = rs.getString("c_id");
out.print("<tr><td>"+"<input type='checkbox' name='a' value="+c_id+" onclick='testfun( this ,"+c_id+")'>"+"</td>" + "<td><input type='text' id='"+c_id+"' name='count' value=0 SIZE=5></td><td>"+name+"</td></tr> ");
}
rs.close();
%>
</tbody>
</table>
</form>
</div>
<script type="text/javascript">
function testfun(element, c_id) {
var x = document.getElementById(c_id);
window.alert(c_id);
if (element.checked) {
x.value =1;
} else {
x.value = 0;
}
}
</script>
謝謝大家