function fwrite_submit(f) 에서 content 앞뒤로 문자열추가

function fwrite_submit(f) 에서 content 앞뒤로 문자열추가

QA

function fwrite_submit(f) 에서 content 앞뒤로 문자열추가

본문

안녕하세요. 

질문그대로 글쓰기시 자동으로 입력된 내용 앞뒤로 문자열을 추가해서 submit 하고자 합니다.

 

에를들어 본문 내용이 '안녕하세요.' 이면 자동으로

 

여러분 안녕하세요. 반갑습니다. 

 

와 같이 여러분 과 반갑습니다. 를 붙여서 submit 하는겁니다. 

 

function fwrite_submit(f) 에서 아래의 코드 부분에 해당내용을 추가하면 될거같은데

문법이 약해서 계속 에러만 떨어지네요.;;;

조언부탁드립니다. 감사합니다.

 

 

 

function fwrite_submit(f) {
    <?php echo $editor_js; ?> // 에디터 사용시 자바스크립트에서 내용을 폼필드로 넣어주며 내용이 입력되었는지 검사함
    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: "제목에 금지단어 '<strong class='text-crimson'>"+subject+"</strong>' 단어가 포함되어있습니다.",
            confirmButtonColor: "#e53935",
            icon: "error",
            confirmButtonText: "확인"
        });
        f.wr_subject.focus();
        return false;
    }
    if (content) {
        Swal.fire({
            title: "알림!",
            text: "내용에 금지단어 '<strong class='text-crimson'>"+content+"</strong>' 단어가 포함되어있습니다.",
            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: "내용은 <strong class='text-crimson'>"+char_min+"</strong> 글자 이상 쓰셔야 합니다.",
                    confirmButtonColor: "#e53935",
                    icon: "error",
                    confirmButtonText: "확인"
                });
                return false;
            }
            else if (char_max > 0 && char_max < cnt) {
                Swal.fire({
                    title: "알림!",
                    html: "내용은 <strong class='text-crimson'>"+char_max+"</strong> 글자 이하로 쓰셔야 합니다.",
                    confirmButtonColor: "#e53935",
                    icon: "error",
                    confirmButtonText: "확인"
                });
                return false;
            }
        }
    }
    <?php echo $captcha_js; ?> // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함
    document.getElementById("btn_submit").disabled = "disabled";
    return true;
}

 

이 질문에 댓글 쓰기 :

답변 2

f.wr_content.value 가 내용이라서요.

f.wr_content.value = "여러분 반갑습니다. "+f.wr_content.value;

 

이런식으로 마지막단에 넣으시면 됩니다.



function fwrite_submit(f) {

f.wr_content.value = "여러분 반갑습니다. "+f.wr_content.value;
}
답변을 작성하시기 전에 로그인 해주세요.
전체 123,844 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT