function fwrite_submit(f) 에서 content 앞뒤로 문자열추가 채택완료
안녕하세요.
질문그대로 글쓰기시 자동으로 입력된 내용 앞뒤로 문자열을 추가해서 submit 하고자 합니다.
에를들어 본문 내용이 '안녕하세요.' 이면 자동으로
여러분 안녕하세요. 반갑습니다.
와 같이 여러분 과 반갑습니다. 를 붙여서 submit 하는겁니다.
function fwrite_submit(f) 에서 아래의 코드 부분에 해당내용을 추가하면 될거같은데
문법이 약해서 계속 에러만 떨어지네요.;;;
조언부탁드립니다. 감사합니다.
Copy
function fwrite_submit(f) {
// 에디터 사용시 자바스크립트에서 내용을 폼필드로 넣어주며 내용이 입력되었는지 검사함
var subject = "";
var content = "";
$.ajax({
url: g5_bbs_url+"/ajax.filter.php",
type: "POST",
data: {
"subject": f.wr_subject.value,
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
subject = data.subject;
content = data.content;
}
});
if (subject) {
Swal.fire({
title: "알림!",
html: "제목에 금지단어 '"+subject+"' 단어가 포함되어있습니다.",
confirmButtonColor: "#e53935",
icon: "error",
confirmButtonText: "확인"
});
f.wr_subject.focus();
return false;
}
if (content) {
Swal.fire({
title: "알림!",
text: "내용에 금지단어 '"+content+"' 단어가 포함되어있습니다.",
confirmButtonColor: "#e53935",
icon: "error",
confirmButtonText: "확인"
});
if (typeof(ed_wr_content) != "undefined")
ed_wr_content.returnFalse();
else
f.wr_content.focus();
return false;
}
if (document.getElementById("char_count")) {
if (char_min > 0 || char_max > 0) {
var cnt = parseInt(check_byte("wr_content", "char_count"));
if (char_min > 0 && char_min > cnt) {
Swal.fire({
title: "알림!",
html: "내용은 "+char_min+" 글자 이상 쓰셔야 합니다.",
confirmButtonColor: "#e53935",
icon: "error",
confirmButtonText: "확인"
});
return false;
}
else if (char_max > 0 && char_max cnt) {
Swal.fire({
title: "알림!",
html: "내용은 "+char_max+" 글자 이하로 쓰셔야 합니다.",
confirmButtonColor: "#e53935",
icon: "error",
confirmButtonText: "확인"
});
return false;
}
}
}
// 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함
document.getElementById("btn_submit").disabled = "disabled";
return true;
}
답변 2개
채택된 답변
+20 포인트
Min아빠
1년 전
f.wr_content.value 가 내용이라서요.
f.wr_content.value = "여러분 반갑습니다. "+f.wr_content.value;
이런식으로 마지막단에 넣으시면 됩니다.
Copy
function fwrite_submit(f) {
f.wr_content.value = "여러분 반갑습니다. "+f.wr_content.value;
}
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
devdev
1년 전
<?php echo $captcha_js; ?> 해당 라인 아래 다음처럼 넣고 실행해보세요.
f.wr_content.value = "여러분 "+f.wr_content.value +" 반갑습니다";
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인