불당님이 jQuery 하시길래 몇일 살펴보았는데 상당히 만족스럽네요.
처음 만들어보는거라 코드가 지저분합니다.
jQuery 잘 아시는 분들은 수정 후 좀 알려주십시오.
<input type=button value='행추가' id='add-row'>
<input type=button value='열추가' id='add-col'>
<input type=button value='행삭제' id='del-row'>
<input type=button value='열삭제' id='del-col'>
<table id='stock_table' border=0>
<thead id='stock_thead'>
<tr>
<td>
<input type=text name=it_opty_subj size=4 class=ed value='<?=$it[it_opty_subj]?>'>
<input type=text name=it_optx_subj size=4 class=ed value='<?=$it[it_optx_subj]?>'>
</td>
<td>
<input type=text name='optx_subj[0]' size=5 class=ed>
</td>
</tr>
</thead>
<tbody id='stock_tbody'>
<tr>
<td><input type=text name='opty_subj[0]' size=10 class=ed></td>
<td><input type=text name='opt[0][0]' size=5 class=ed></td>
</tr>
</tbody>
</table>
... 중략 ...
<script>
var stock_x = 0;
var stock_y = 0;
$(document).ready(function() {
// 행추가
$('#add-row').click(function() {
stock_y++;
var s = "<tr>";
s += "<td><input type=text name='opty_subj["+stock_y+"]' size=10 class=ed></td>"; // 행 제목 추가
var len = $('#stock_thead td').length; // 열의 갯수에 따라 추가된 행의 열 추가
for (i=0; i<len-1; i++) {
s += "<td><input type=text name='opt["+stock_y+"]["+i+"]' size=5 class=ed></td>";
}
s += "</tr>";
$('#stock_tbody').append(s);
});
// 열추가
$('#add-col').click(function() {
stock_x++;
$('#stock_thead tr').append("<td><input type=text name='optx_subj["+stock_x+"]' size=5 class=ed></td>");
$('#stock_tbody tr').each(function(index) {
$(this).append("<td><input type=text name='opt["+index+"]["+stock_x+"]' size=5 class=ed></td>");
});
});
// 행삭제
$('#del-row').click(function() {
if (stock_y > 0) {
$('#stock_tbody tr:last').remove();
stock_y--;
}
});
// 열삭제
$('#del-col').click(function() {
if (stock_x > 0) {
$('#stock_thead td:last').remove();
$('#stock_tbody tr').each(function(index) {
$('td:last', this).remove();
});
stock_x--;
}
});
});
</script>
댓글 4개
<script language="JavaScript" src="<?="$g4[path]/js/board.js"?>"></script>
<script language="JavaScript">
window.onload=function() {
resizeBoardImage(<?=(int)$board[bo_image_width]?>);
drawFont();
}
</script>
차후에는 전부 jQuery 로 ~
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 360 | ||
| 7929 | 9년 전 | 250 | ||
| 7928 | 9년 전 | 359 | ||
| 7927 | 9년 전 | 285 | ||
| 7926 | 9년 전 | 636 | ||
| 7925 | 9년 전 | 303 | ||
| 7924 | 9년 전 | 266 | ||
| 7923 | 9년 전 | 315 | ||
| 7922 | 9년 전 | 331 | ||
| 7921 | 9년 전 | 367 | ||
| 7920 | 9년 전 | 288 | ||
| 7919 | 9년 전 | 301 | ||
| 7918 | 9년 전 | 471 | ||
| 7917 | 9년 전 | 309 | ||
| 7916 | 9년 전 | 372 | ||
| 7915 | 9년 전 | 355 | ||
| 7914 | 9년 전 | 377 | ||
| 7913 | 9년 전 | 494 | ||
| 7912 | 9년 전 | 369 | ||
| 7911 | 9년 전 | 325 | ||
| 7910 | 9년 전 | 349 | ||
| 7909 | 9년 전 | 455 | ||
| 7908 | 9년 전 | 362 | ||
| 7907 | 9년 전 | 310 | ||
| 7906 | 9년 전 | 325 | ||
| 7905 | 9년 전 | 320 | ||
| 7904 | 9년 전 | 279 | ||
| 7903 | 9년 전 | 281 | ||
| 7902 | 9년 전 | 503 | ||
| 7901 |
|
9년 전 | 712 | |
| 7900 | 9년 전 | 535 | ||
| 7899 | 9년 전 | 339 | ||
| 7898 | 9년 전 | 334 | ||
| 7897 | 9년 전 | 293 | ||
| 7896 | 9년 전 | 310 | ||
| 7895 | 9년 전 | 419 | ||
| 7894 | 9년 전 | 343 | ||
| 7893 | 9년 전 | 269 | ||
| 7892 | 9년 전 | 310 | ||
| 7891 | 9년 전 | 698 | ||
| 7890 | 9년 전 | 1164 | ||
| 7889 | 9년 전 | 725 | ||
| 7888 |
limsy1987
|
9년 전 | 513 | |
| 7887 | 9년 전 | 498 | ||
| 7886 | 9년 전 | 374 | ||
| 7885 | 9년 전 | 353 | ||
| 7884 | 9년 전 | 359 | ||
| 7883 | 9년 전 | 334 | ||
| 7882 | 9년 전 | 350 | ||
| 7881 | 9년 전 | 369 | ||
| 7880 | 9년 전 | 503 | ||
| 7879 | 9년 전 | 408 | ||
| 7878 | 9년 전 | 1138 | ||
| 7877 | 9년 전 | 701 | ||
| 7876 | 9년 전 | 425 | ||
| 7875 | 9년 전 | 496 | ||
| 7874 |
|
9년 전 | 769 | |
| 7873 | 9년 전 | 475 | ||
| 7872 | 9년 전 | 599 | ||
| 7871 | 9년 전 | 439 | ||
| 7870 | 9년 전 | 557 | ||
| 7869 | 9년 전 | 383 | ||
| 7868 | 9년 전 | 367 | ||
| 7867 | 9년 전 | 370 | ||
| 7866 | 9년 전 | 427 | ||
| 7865 | 9년 전 | 390 | ||
| 7864 | 9년 전 | 449 | ||
| 7863 | 9년 전 | 441 | ||
| 7862 | 9년 전 | 419 | ||
| 7861 | 9년 전 | 583 | ||
| 7860 | 9년 전 | 589 | ||
| 7859 | 9년 전 | 360 | ||
| 7858 | 9년 전 | 663 | ||
| 7857 | 9년 전 | 1017 | ||
| 7856 | 9년 전 | 470 | ||
| 7855 | 9년 전 | 690 | ||
| 7854 | 9년 전 | 691 | ||
| 7853 | 9년 전 | 521 | ||
| 7852 | 9년 전 | 464 | ||
| 7851 | 9년 전 | 436 | ||
| 7850 | 9년 전 | 533 | ||
| 7849 | 9년 전 | 307 | ||
| 7848 | 9년 전 | 345 | ||
| 7847 | 9년 전 | 569 | ||
| 7846 | 9년 전 | 399 | ||
| 7845 | 9년 전 | 363 | ||
| 7844 | 9년 전 | 354 | ||
| 7843 | 9년 전 | 365 | ||
| 7842 | 9년 전 | 359 | ||
| 7841 | 9년 전 | 348 | ||
| 7840 | 9년 전 | 351 | ||
| 7839 | 9년 전 | 384 | ||
| 7838 | 9년 전 | 471 | ||
| 7837 | 9년 전 | 313 | ||
| 7836 | 9년 전 | 353 | ||
| 7835 | 9년 전 | 431 | ||
| 7834 |
|
9년 전 | 1165 | |
| 7833 | 9년 전 | 372 | ||
| 7832 | 9년 전 | 358 | ||
| 7831 | 9년 전 | 492 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기