불당님이 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 로 ~
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2130 | 17년 전 | 1181 | ||
| 2129 |
ⓧ힘내세요
|
17년 전 | 2236 | |
| 2128 | 17년 전 | 2872 | ||
| 2127 | 17년 전 | 4056 | ||
| 2126 | 17년 전 | 3144 | ||
| 2125 | 17년 전 | 1407 | ||
| 2124 | 17년 전 | 1707 | ||
| 2123 | 17년 전 | 2237 | ||
| 2122 | 17년 전 | 1544 | ||
| 2121 | 17년 전 | 1720 | ||
| 2120 | 17년 전 | 2718 | ||
| 2119 | 17년 전 | 2143 | ||
| 2118 | 17년 전 | 1797 | ||
| 2117 |
아름다운세상
|
17년 전 | 4207 | |
| 2116 | 17년 전 | 3049 | ||
| 2115 | 17년 전 | 1435 | ||
| 2114 |
아름다운세상
|
17년 전 | 3569 | |
| 2113 | 17년 전 | 2794 | ||
| 2112 | 17년 전 | 2074 | ||
| 2111 | 17년 전 | 1292 | ||
| 2110 | 17년 전 | 2332 | ||
| 2109 | 17년 전 | 2066 | ||
| 2108 | 17년 전 | 1989 | ||
| 2107 |
휴전합시다
|
17년 전 | 1919 | |
| 2106 | 17년 전 | 1168 | ||
| 2105 |
|
17년 전 | 1871 | |
| 2104 | 17년 전 | 2927 | ||
| 2103 | 17년 전 | 1432 | ||
| 2102 | 17년 전 | 1670 | ||
| 2101 | 17년 전 | 1354 | ||
| 2100 | 17년 전 | 1601 | ||
| 2099 | 17년 전 | 1574 | ||
| 2098 | 17년 전 | 1446 | ||
| 2097 | 17년 전 | 2559 | ||
| 2096 | 17년 전 | 2327 | ||
| 2095 | 17년 전 | 2109 | ||
| 2094 | 17년 전 | 1421 | ||
| 2093 | 17년 전 | 2432 | ||
| 2092 | 17년 전 | 4262 | ||
| 2091 | 17년 전 | 2750 | ||
| 2090 | 17년 전 | 1664 | ||
| 2089 | 17년 전 | 1856 | ||
| 2088 | 17년 전 | 3238 | ||
| 2087 | 17년 전 | 2234 | ||
| 2086 | 17년 전 | 3832 | ||
| 2085 | 17년 전 | 1679 | ||
| 2084 | 17년 전 | 2285 | ||
| 2083 | 17년 전 | 2108 | ||
| 2082 | 17년 전 | 1613 | ||
| 2081 | 17년 전 | 2128 | ||
| 2080 |
letsgolee
|
17년 전 | 1921 | |
| 2079 | 17년 전 | 1961 | ||
| 2078 | 17년 전 | 3072 | ||
| 2077 | 17년 전 | 2147 | ||
| 2076 | 17년 전 | 1441 | ||
| 2075 | 17년 전 | 1460 | ||
| 2074 | 17년 전 | 2128 | ||
| 2073 | 17년 전 | 3206 | ||
| 2072 | 17년 전 | 2137 | ||
| 2071 |
휴전합시다
|
17년 전 | 1532 | |
| 2070 | 17년 전 | 4245 | ||
| 2069 | 17년 전 | 2041 | ||
| 2068 | 17년 전 | 3460 | ||
| 2067 | 17년 전 | 6039 | ||
| 2066 | 17년 전 | 1483 | ||
| 2065 |
letsgolee
|
17년 전 | 1654 | |
| 2064 | 17년 전 | 1235 | ||
| 2063 | 17년 전 | 1349 | ||
| 2062 |
vicky
|
17년 전 | 2874 | |
| 2061 | 17년 전 | 1909 | ||
| 2060 |
카프카07
|
17년 전 | 2594 | |
| 2059 | 17년 전 | 1309 | ||
| 2058 | 17년 전 | 3184 | ||
| 2057 | 17년 전 | 2164 | ||
| 2056 | 17년 전 | 2611 | ||
| 2055 | 17년 전 | 1406 | ||
| 2054 | 17년 전 | 1758 | ||
| 2053 | 17년 전 | 1149 | ||
| 2052 |
|
17년 전 | 1204 | |
| 2051 | 17년 전 | 1792 | ||
| 2050 | 17년 전 | 1230 | ||
| 2049 | 17년 전 | 4313 | ||
| 2048 | 17년 전 | 1512 | ||
| 2047 | 17년 전 | 2010 | ||
| 2046 |
카프카07
|
17년 전 | 7091 | |
| 2045 | 17년 전 | 1384 | ||
| 2044 | 17년 전 | 1904 | ||
| 2043 | 17년 전 | 3133 | ||
| 2042 | 17년 전 | 1227 | ||
| 2041 |
카프카07
|
17년 전 | 1986 | |
| 2040 | 17년 전 | 1166 | ||
| 2039 |
smilesol
|
17년 전 | 1852 | |
| 2038 | 17년 전 | 2155 | ||
| 2037 |
|
17년 전 | 2971 | |
| 2036 | 17년 전 | 1247 | ||
| 2035 |
|
17년 전 | 1343 | |
| 2034 |
ㅣ곰탱이ㅣ
|
17년 전 | 1564 | |
| 2033 |
|
17년 전 | 1232 | |
| 2032 | 17년 전 | 4360 | ||
| 2031 | 17년 전 | 3899 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기