I have a php-function trans
to translate text. How to input trans
-output in javascript?
<script>
function fregister_submit(f) {
if (!f.agree.checked) {
alert("<?=trans('회원가입약관의 내용에 동의하셔야 회원가입 하실 수 있습니다.')?>");
f.agree.focus();
return false;
}
if (!f.agree2.checked) {
alert("개인정보처리방침안내의 내용에 동의하셔야 회원가입 하실 수 있습니다.");
f.agree2.focus();
return false;
}
return true;
}
Try this:
alert("<? echo trans('회원가입약관의 내용에 동의하셔야 회원가입 하실 수 있습니다.'); ?>");
Converting php variables to be readable for javascript can be done like this:
<?php echo json_encode($var); ?>;
Everything else a simple echo does the job