코멘트에 추가필드 적용하기
코멘트에 추가필드(wr_1~10)를 적용하면 입력과 출력은 잘 되는데 수정을 할때 문제가 있습니다.
수정을 하면 기존에 입력된 내용이 안나오고 처음 작성할때 처럼 빈 내용만 나옵니다.
이 문제로 질답게시판게 글을 올렸는데 엑스엠엘님이 답을 주셔서 제가 해결한 방법을 올립니다.
엑스엠엘님께 감사 드립니다.
4.33.02 (11.01.24)버전 view_comment.skin.php 파일 기준입니다.
================================================================
1. 코멘트 출력에 소스추가
67라인
<input type=hidden id='secret_comment_<?=$comment_id?>' value="<?=strstr($list[$i][wr_option],"secret")?>">
밑에 아래소스 추가
<textarea id='save_comment_<?=$comment_id?>_wr_1' style='display:none;'><?=get_text($list[$i][wr_1], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_2' style='display:none;'><?=get_text($list[$i][wr_2], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_3' style='display:none;'><?=get_text($list[$i][wr_3], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_4' style='display:none;'><?=get_text($list[$i][wr_4], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_5' style='display:none;'><?=get_text($list[$i][wr_5], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_6' style='display:none;'><?=get_text($list[$i][wr_6], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_7' style='display:none;'><?=get_text($list[$i][wr_7], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_8' style='display:none;'><?=get_text($list[$i][wr_8], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_9' style='display:none;'><?=get_text($list[$i][wr_9], 0)?></textarea>
<textarea id='save_comment_<?=$comment_id?>_wr_10' style='display:none;'><?=get_text($list[$i][wr_10], 0)?></textarea>
2. 각 <input 에 id적용
118라인
<td width=95%>
밑에 아래소스 추가
추가필드1 : <input id='wr_1' type=text name='wr_1' class='ed' style='width:50%' required itemname='추가필드1' value="<?=$write[wr_1]?>"><br />
추가필드2 : <input id='wr_2' type=text name='wr_2' class='ed' style='width:90%' required itemname='추가필드2' value="<?=$write[wr_2]?>"><br />
추가필드3 : <input id='wr_3' type=text name='wr_3' class='ed' style='width:20%' required itemname='추가필드3' value="<?=$write[wr_3]?>"><br />
추가필드4 : <input id='wr_4' type=text name='wr_4' class='ed' style='width:20%' required itemname='추가필드4' value="<?=$write[wr_4]?>"><br />
추가필드5 : <input id='wr_5' type=text name='wr_5' class='ed' style='width:20%' required itemname='추가필드5' value="<?=$write[wr_5]?>"><br />
추가필드6 : <input id='wr_6' type=text name='wr_6' class='ed' style='width:20%' required itemname='추가필드6' value="<?=$write[wr_6]?>"><br />
추가필드7 : <input id='wr_7' type=text name='wr_7' class='ed' style='width:20%' required itemname='추가필드7' value="<?=$write[wr_7]?>"><br />
추가필드8 : <input id='wr_8' type=text name='wr_8' class='ed' style='width:20%' required itemname='추가필드8' value="<?=$write[wr_8]?>"><br />
추가필드9 : <input id='wr_9' type=text name='wr_9' class='ed' style='width:20%' required itemname='추가필드9' value="<?=$write[wr_9]?>"><br />
추가필드10 : <input id='wr_10' type=text name='wr_10' class='ed' style='width:20%' required itemname='추가필드10' value="<?=$write[wr_10]?>"><br />
3. 스크립트 추가
292라인
document.getElementById('wr_content').value = document.getElementById('save_comment_' + comment_id).value;
밑에 아래소스 추가
document.getElementById('wr_1').value = document.getElementById('save_comment_' + comment_id+'_wr_1').value;
document.getElementById('wr_2').value = document.getElementById('save_comment_' + comment_id+'_wr_2').value;
document.getElementById('wr_3').value = document.getElementById('save_comment_' + comment_id+'_wr_3').value;
document.getElementById('wr_4').value = document.getElementById('save_comment_' + comment_id+'_wr_4').value;
document.getElementById('wr_5').value = document.getElementById('save_comment_' + comment_id+'_wr_5').value;
document.getElementById('wr_6').value = document.getElementById('save_comment_' + comment_id+'_wr_6').value;
document.getElementById('wr_7').value = document.getElementById('save_comment_' + comment_id+'_wr_7').value;
document.getElementById('wr_8').value = document.getElementById('save_comment_' + comment_id+'_wr_8').value;
document.getElementById('wr_9').value = document.getElementById('save_comment_' + comment_id+'_wr_9').value;
document.getElementById('wr_10').value = document.getElementById('save_comment_' + comment_id+'_wr_10').value;
============================================================================
여기까지 입니다.
2% 부족한게 있는데 추가 필드 입력방식이 텍스트가 아니라 셀렉트나 라디오버튼일 경우 입니다.
이경우 수정시 68라인 근처에서 어떻게 처리를 해야하는지 제가 해결 능력이 안되어 2% 부족한 상태로 올립니다.
혹시라도 해결 방법을 아시거나 해결하신 분이 계시면 좀 알려주시기 바랍니다.
감사합니다. ^^
댓글 4개
보이기가 되질 않아요.....
이런식으로 하면 나오지 않을까요?
게시판 목록
그누4 팁자료실
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3129 | 12년 전 | 5176 | ||
| 3128 | 12년 전 | 7911 | ||
| 3127 | 12년 전 | 7064 | ||
| 3126 | 12년 전 | 4986 | ||
| 3125 | 12년 전 | 5869 | ||
| 3124 | 12년 전 | 5557 | ||
| 3123 | 12년 전 | 5924 | ||
| 3122 | 12년 전 | 6171 | ||
| 3121 | 12년 전 | 5520 | ||
| 3120 | 12년 전 | 5817 | ||
| 3119 | 12년 전 | 5238 | ||
| 3118 | 12년 전 | 4673 | ||
| 3117 | 12년 전 | 4448 | ||
| 3116 | 12년 전 | 7208 | ||
| 3115 | 12년 전 | 6033 | ||
| 3114 |
생각하는바보
|
12년 전 | 6412 | |
| 3113 |
|
12년 전 | 4822 | |
| 3112 |
|
12년 전 | 5208 | |
| 3111 |
|
12년 전 | 3642 | |
| 3110 |
|
12년 전 | 4083 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기