불당님이 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 로 ~
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2230 | 16년 전 | 1293 | ||
| 2229 | 16년 전 | 2161 | ||
| 2228 | 16년 전 | 3226 | ||
| 2227 | 16년 전 | 2173 | ||
| 2226 | 16년 전 | 1756 | ||
| 2225 | 16년 전 | 1519 | ||
| 2224 |
|
16년 전 | 2049 | |
| 2223 | 16년 전 | 4732 | ||
| 2222 | 16년 전 | 1417 | ||
| 2221 |
|
16년 전 | 2149 | |
| 2220 |
|
16년 전 | 2139 | |
| 2219 |
|
16년 전 | 2408 | |
| 2218 |
|
16년 전 | 2151 | |
| 2217 |
|
16년 전 | 4440 | |
| 2216 |
|
16년 전 | 2931 | |
| 2215 | 16년 전 | 2869 | ||
| 2214 | 16년 전 | 1606 | ||
| 2213 | 16년 전 | 1253 | ||
| 2212 |
|
16년 전 | 3956 | |
| 2211 |
|
16년 전 | 1623 | |
| 2210 |
|
16년 전 | 1622 | |
| 2209 | 16년 전 | 2116 | ||
| 2208 | 16년 전 | 1888 | ||
| 2207 |
letsgolee
|
16년 전 | 1499 | |
| 2206 |
|
16년 전 | 3929 | |
| 2205 | 16년 전 | 1767 | ||
| 2204 | 16년 전 | 3141 | ||
| 2203 | 16년 전 | 3029 | ||
| 2202 | 16년 전 | 1053 | ||
| 2201 | 16년 전 | 1847 | ||
| 2200 | 16년 전 | 1601 | ||
| 2199 |
|
16년 전 | 1859 | |
| 2198 |
태양의서쪽
|
16년 전 | 2655 | |
| 2197 |
태양의서쪽
|
16년 전 | 3032 | |
| 2196 |
태양의서쪽
|
16년 전 | 3231 | |
| 2195 | 16년 전 | 3329 | ||
| 2194 | 16년 전 | 1472 | ||
| 2193 |
letsgolee
|
16년 전 | 1428 | |
| 2192 | 16년 전 | 2258 | ||
| 2191 | 17년 전 | 1980 | ||
| 2190 |
|
17년 전 | 2292 | |
| 2189 | 17년 전 | 2814 | ||
| 2188 |
Sizkein
|
17년 전 | 3262 | |
| 2187 |
letsgolee
|
17년 전 | 2361 | |
| 2186 |
Sizkein
|
17년 전 | 1637 | |
| 2185 |
Sizkein
|
17년 전 | 3210 | |
| 2184 |
Sizkein
|
17년 전 | 3066 | |
| 2183 | 17년 전 | 3042 | ||
| 2182 | 17년 전 | 3924 | ||
| 2181 | 17년 전 | 2589 | ||
| 2180 |
|
17년 전 | 2410 | |
| 2179 | 17년 전 | 2656 | ||
| 2178 | 17년 전 | 2903 | ||
| 2177 | 17년 전 | 2621 | ||
| 2176 | 17년 전 | 1458 | ||
| 2175 | 17년 전 | 1899 | ||
| 2174 | 17년 전 | 1497 | ||
| 2173 |
|
17년 전 | 1925 | |
| 2172 | 17년 전 | 2528 | ||
| 2171 | 17년 전 | 8711 | ||
| 2170 | 17년 전 | 3165 | ||
| 2169 | 17년 전 | 4252 | ||
| 2168 |
|
17년 전 | 1995 | |
| 2167 | 17년 전 | 3661 | ||
| 2166 |
|
17년 전 | 1560 | |
| 2165 | 17년 전 | 1391 | ||
| 2164 | 17년 전 | 2328 | ||
| 2163 | 17년 전 | 1322 | ||
| 2162 | 17년 전 | 1644 | ||
| 2161 | 17년 전 | 1462 | ||
| 2160 | 17년 전 | 2533 | ||
| 2159 |
inxps
|
17년 전 | 1506 | |
| 2158 |
inxps
|
17년 전 | 1100 | |
| 2157 | 17년 전 | 1233 | ||
| 2156 | 17년 전 | 3113 | ||
| 2155 | 17년 전 | 2183 | ||
| 2154 | 17년 전 | 1984 | ||
| 2153 |
|
17년 전 | 1225 | |
| 2152 |
letsgolee
|
17년 전 | 2456 | |
| 2151 | 17년 전 | 1176 | ||
| 2150 |
아름다운세상
|
17년 전 | 1133 | |
| 2149 |
아름다운세상
|
17년 전 | 1381 | |
| 2148 |
아름다운세상
|
17년 전 | 2743 | |
| 2147 |
|
17년 전 | 2401 | |
| 2146 | 17년 전 | 2489 | ||
| 2145 | 17년 전 | 1190 | ||
| 2144 | 17년 전 | 1308 | ||
| 2143 | 17년 전 | 3255 | ||
| 2142 | 17년 전 | 2841 | ||
| 2141 | 17년 전 | 4113 | ||
| 2140 | 17년 전 | 2260 | ||
| 2139 | 17년 전 | 2349 | ||
| 2138 | 17년 전 | 1404 | ||
| 2137 | 17년 전 | 2518 | ||
| 2136 | 17년 전 | 2202 | ||
| 2135 | 17년 전 | 2963 | ||
| 2134 |
아름다운세상
|
17년 전 | 2473 | |
| 2133 |
Juinjang
|
17년 전 | 1636 | |
| 2132 | 17년 전 | 2435 | ||
| 2131 | 17년 전 | 1592 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기