테스트 사이트 - 개발 중인 베타 버전입니다

php 구문 질문드립니다 2 채택완료

갱쿤 8년 전 조회 2,193

13번라인에 

 

!= -1) { alert(\"내용을 입력해 주십시오.\"); oEditors.getById['{$id}'].exec('FOCUS'); return false; }\n"; 

 

alert(\"내용을 입력해 주십시오.\");

 

이 내용을 번역으로 적용 하려고 합니다.

 

!= -1) {

if($lang =="kr") {alert(\"안녕.\");} 

if($lang =="en") { alert(\"hi.\");}

 oEditors.getById['{$id}'].exec('FOCUS'); return false; }\n"; 

위처럼 하면 kr일때는 안녕으로 나오고 en일때는 hi라는 문구로 경고창 문구를 변경하고 싶은데 Retun"" 안에 if문을 사용하는 방법이 있는지 질문드립니다 ^^; 

 

설명이 너무 복잡한것같은데 이게 설명이 어렵네요 ^^;; 

 

 

 

 

- 원본 소스

 

</p><p>//  textarea 의 값이 비어 있는지 검사 hyun</p><p>function chk_editor_js($id, $is_dhtml_editor=true)</p><p>{</p><p>    if ($is_dhtml_editor) {</p><p>        return "</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>var {$id}_editor_data_txt = {$id}_editor_data.toLowerCase();\n;</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>{$id}_editor_data_txt = {$id}_editor_data_txt.replace(/\<p\>/gi, '');\n;</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>{$id}_editor_data_txt = {$id}_editor_data_txt.replace(/\<br\>/gi, '');\n;</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>{$id}_editor_data_txt = {$id}_editor_data_txt.replace(/\<\/p\>/gi, '');\n;</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>{$id}_editor_data_txt = {$id}_editor_data_txt.replace(/ /gi, '');\n;</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>{$id}_editor_data_txt = {$id}_editor_data_txt.replace(/ /gi, '');\n;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre">		</span>if (!{$id}_editor_data_txt || !{$id}_edito</p><p><span class="Apple-tab-span" style="white-space:pre">		</span>r_data || jQuery.inArray({$id}_editor_data.toLowerCase(), [' ','  ','   ','<p> </p>','<p>  </p>','<p>   </p>','<p>    </p>','<p>
</p>','<p></p>','
']) != -1) { alert(\"내용을 입력해 주십시오.\"); oEditors.getById['{$id}'].exec('FOCUS'); return false; }\n";</p><p>    } else {</p><p>        return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";</p><p>    }</p><p>}</p><p>

 

 

 

 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트

리턴 전에 변수에 담아서 처리하는 것이 좋을 것 같네요.

 

</strong></p><p>$alt_str = "";</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><span style="font-size: 14.6667px;"><b>if($lang =="kr")</b></span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><span style="font-size: 14.6667px;"><b>  </b></span><span style="font-size: 14.6667px; font-family: 돋움;">$alt_str = "안녕";</span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><span style="font-size: 14.6667px;"><b>else if($lang =="en")</b></span></p><p><span style="color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.6667px;"><b>  </b></span><span style="color: rgb(72, 72, 72); font-size: 14.6667px;">$alt_str = "hi";</span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><b style="font-size: 14.6667px;">alert(</b><span style="font-family: 돋움; font-size: 14.6667px;">$alt_str</span><b style="font-size: 14.6667px;">);</b> </p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><strong style="color: rgb(127, 127, 127); font-size: 12px;">
 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

갱쿤
8년 전
감사합니다~ ㅎㅎ

댓글을 작성하려면 로그인이 필요합니다.

OrLl
8년 전

그냥 엘스 안에 이렇게 느면안되요?

if($lang =="kr") {alert(\"안녕.\");} 

if($lang =="en") { alert(\"hi.\");}

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인