특정문자제거 문의드립니다. 채택완료
텍스트에리아에 적은 내용 pt_msg1을
pre태그에 그대로 보이도록 하는데요
하단에 업체명 경력내용 기간에 각각 값이 없을경우 안보이게 문자제거를 하는방법이 없을까요
*적는칸
<textarea name="pt_msg1" id="pt_msg1" class="frm_input sl">
<?php echo get_text(cut_str($it['pt_msg1'], 250, "")); ?>
</textarea>
*불러오는칸
<pre class="toge01" style="margin-bottom:0; padding-bottom:0; margin-top: 7px;">
<span class="undefine">
<?php echo rtrim($it['pt_msg1']);?>
</span>
</pre>
*결과값
<span class="undefine">
● 업체명 : 공이중개사
○ 경력내용 : 궁새
○ 기간 : 1
● 업체명 :
○ 경력내용 :
○ 기간 :
● 업체명 :
○ 경력내용 :
○ 기간 :
● 업체명 :
○ 경력내용 :
○ 기간 :
● 업체명 :
○ 경력내용 :
○ 기간 :
</span>
답변 1개
적어 주신 내용 대로 출력을 하는거라면 textarea가 아니라 따로 입력 받을 수 있는 폼을 만드시는게 좋을것 같습니다.
저같은 경우는

이런식으로 폼을 만들어 두고 +를 눌럿을때 밑으로 폼이 추가 되고 해당 내용은 json 값으로 컬럼에 넣은후 출력 할때는 json 파싱 해서 출력 해 줍니다.
답변에 대한 댓글 2개
input만 클릭해도 값이없어도 절로 표출되서요...
소스 공유좀요~
<tr class="layer layer01" style=" display:none;width:650%; float:left; ">
<th scope="row" style="width:15.5% !important; float:left; padding-top: 87px; padding-bottom: 91px;"><label>자격내용</label></th>
<td class="one_t" style="width:84.5%; float:left; ">
<textarea style="height:175px !important; padding-left:0; padding-top:40px;" name="pt_msg2" id="pt_msg2" class="frm_input sl"><?php echo get_text(cut_str($it['pt_msg2'], 250, "")); ?></textarea>
</td>
</tr>
<?php if ($w == '') { ?>
<tr class="layer good_line layer02"><!--폼에적는곳 3개-->
<th scope="row"><label>자격내용</label></th>
<td style="position:relative;">
<div id="pre_set2" class="pre_set2" >
<input placeholder="발행처 예)한국인력공단" id="item21" class="tt21" type="text" name="" value="" style="width:160px; margin-right:5px;" onkeyup="myFunction2()">
<input placeholder="자격증명 예)공인중개사" id="item22" class="tt22" type="text" name="" value="" style="width:277px; margin-right:5px;" onkeyup="myFunction2()">
<input placeholder="교부일 예)24회 2016.01.01" id="item23" class="tt23" type="text" name="" value="" style="width:203px; margin-right:5px;" onkeyup="myFunction2()">
<input type="button" class="meiyou" value="삭제" onclick="remove_item2(this)">
</div>
<div id="field2"></div>
<input style="position:absolute; right:10px; top:13px;" class="plus06" type="button" value=" 추가 " onclick="add_item2()">
</td>
</tr>
<?php } ?>
<script type="text/javascript">
<!--
function add_item2(){
// pre_set2 에 있는 내용을 읽어와서 처리..
var div = document.createElement('div');
div.innerHTML = document.getElementById('pre_set2').innerHTML;
document.getElementById('field2').appendChild(div);
$('#field2>div').addClass("field_div2");
}
function remove_item2(obj){
// obj.parentNode 를 이용하여 삭제
document.getElementById('field2').removeChild(obj.parentNode);
}
//-->
</script>
<!--자격내역 textarea에 값 써지기-->
<script>
function myFunction2() {
var x = '';
$('.pre_set2').each(function() {
x += "\n\n ● 발행처 : " + $('.tt21', $(this)).val() +"\n ○ 자격증명 : " + $('.tt22', $(this)).val() +"\n ○ 교부일 : " + $('.tt23', $(this)).val() + '\n';
});
$('.field_div2').each(function() {
x += "\n ● 발행처 : " + $('.tt21', $(this)).val() +"\n ○ 자격증명 : " + $('.tt22', $(this)).val() +"\n ○ 교부일 : " + $('.tt23', $(this)).val() + '\n';
});
$("#pt_msg2").val(x);
}
</script>
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
소스가 ...ㅠㅠ