댓글에 wr_1필드를 추가해서 사용하는데 댓글 수정시에 ......
본문
안녕하세요
댓글에 유튜브 id를 넣고서
유튜브 api를 이용한 플레이를 하고 싶어서.
wr_1필드를 <input name= wr_1>라고 하고 양식폼을 추가했어요.
그래서 신규로 댓글 입력할 때는 잘됩니다.
그런데
수정할 때에 여기에 기존에 저장된 유튜브 아이디가 보여지게 하고 싶은데....
도저히 안되네요.
<input name= wr_1 value="<? echo $xxxx;?>">
빨간색부분을 어떻게 해야 수정시에는 기존 저장된 내용이 보이고
신규 입력폼에서는 null로 되게할지 알려주시면 정말 감사하겠습니다.
답변 2
<input type="hidden" value="<?php echo strstr($list[$i]['wr_option'],"secret") ?>" id="secret_comment_<?php echo $comment_id ?>">
<textarea id="save_comment_<?php echo $comment_id ?>" style="display:none"><?php echo get_text($list[$i]['content1'], 0) ?></textarea>
<!-- wr_1 값을 숨겨서 저장 -->
<input type="hidden" id="save_wr1_<?php echo $comment_id ?>" value="<?php echo isset($list[$i]['wr_1']) ? get_text($list[$i]['wr_1'], 0) : ''; ?>">
<span class="sound_only">내용</span>
<?php if ($comment_min || $comment_max) { ?><strong id="char_cnt"><span id="char_count"></span>글자</strong><?php } ?>
<textarea id="wr_content" name="wr_content" maxlength="10000" required class="required" title="내용" placeholder="댓글내용을 입력해주세요"
<?php if ($comment_min || $comment_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?php } ?>><?php echo $c_wr_content; ?></textarea>
<!-- 유튜브 ID 입력 필드 -->
<div style="margin-top: 10px;">
<label for="wr_1" class="sound_only">유튜브 ID</label>
<input type="text" name="wr_1" id="wr_1" value="" class="frm_input" placeholder="유튜브 영상 ID를 입력하세요" maxlength="50">
</div>
JS >
// 댓글 수정
if (work == 'cu')
{
// 내용 세팅
document.getElementById('wr_content').value = document.getElementById('save_comment_' + comment_id).value;
// wr_1(유튜브 ID) 세팅
var wr1_el = document.getElementById('save_wr1_' + comment_id);
if (wr1_el) {
document.getElementById('wr_1').value = wr1_el.value;
} else {
document.getElementById('wr_1').value = '';
}
if (typeof char_count != 'undefined')
check_byte('wr_content', 'char_count');
if (document.getElementById('secret_comment_'+comment_id).value)
document.getElementById('wr_secret').checked = true;
else
document.getElementById('wr_secret').checked = false;
}
else
{
// 새 댓글 작성 시 wr_1도 비우기
if (document.getElementById('wr_1')) {
document.getElementById('wr_1').value = '';
}
}
<?php
if($w == '') $write['wr_1'] = "";
?>
<?php echo $write['wr_1'] ?>