jquery - How to add php code in JS file -



jquery - How to add php code in JS file -

im using yii framework web development , text phone call specific php file in order help me exchange language. how have add together message js file, still need yii php phone call text . how that? bellow if coding

i alter "english: 26 character","chinese: 16 character" , "other: 16 character".

because in yii calling text other php this:

in labels.php this:

(eg: 'englishchar'=>'english: 26 character')

so phone call text this:

eg:<?php echo yii::t('labels','englishchar');?> $(function () { $('#select_gametitle').change(function () { var k = $(this).val(); if (k == "e") { $("#txtgametitle").attr("placeholder", "english: 26 characters").placeholder(); $("#txtgametitle").attr('maxlength', '26'); } else if (k == "c") { $("#txtgametitle").attr("placeholder", "chinese: 16 characters").placeholder(); $("#txtgametitle").attr('maxlength', '26'); } else if (k == "o") { $("#txtgametitle").attr("placeholder", "other: 16 characters").placeholder(); $("#txtgametitle").attr('maxlength', '26'); } }); $('input[placeholder], textarea[placeholder]').placeholder(); });

php code:

<div class="inputwrapper"> <div class="usetitle">* <?php echo yii::t('labels', 'gametitle'); ?> :</div> <select id="select_gametitle" name="select_gametitle" class="selectinput" style="width:369px;"> <option value=""><?php echo yii::t('labels', 'select_gametitle'); ?></option> <option value="e"><?php echo yii::t('labels', 'english'); ?></option> <option value="c"><?php echo yii::t('labels', 'chinese'); ?></option> <option value="o"><?php echo yii::t('labels', 'other'); ?></option> </select> <div id="err_select_gametitle" class="error"></div> <input id="txtgametitle" name="txtgametitle" type="text" class="textinput" style="width:352px;" placeholder="" /> </div>

you can add together global var within tags in main layout file.

/view/layouts/main.php:

<?php yii::app()->getclientscript()->registercorescript('jquery.ui'); yii::app()->clientscript->registercssfile(yii::app()->clientscript->getcorescripturl().'/jui/css/base/jquery-ui.css'); ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="language" content="en" /> <link rel="stylesheet" type="text/css" href="<?php echo yii::app()->theme->baseurl; ?>/css/styles.css" /> <title><?php echo chtml::encode($this->pagetitle); ?></title> <?php yii::app()->bootstrap->register(); ?> <link rel="stylesheet" href="<?php echo yii::app()->baseurl; ?>/css/font-awesome-4.0.3/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="<?php echo yii::app()->baseurl; ?>/css/style.css" /> <script> eg:<?php echo yii::t('labels','englishchar');?> </script> </head> <body>

php jquery yii

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -