hi, i have a javascript code, i want to write it in yii, but i dont know how. can any one help me please
the code is:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction()
{
document.getElementById("newtype").value="New text!";
}
</script>
</head>
<body>
Some text: <input type="text" value="hello" onclick="myFunction()">
<input type="text" id="newtype">
</body>
</html>
You can register your javascript by using below example. You may write below script in your view file or controller.
$js = <<<JS
function myFunction()
{
document.getElementById("newtype").value="New text!";
}
JS;
Yii::app()->getClientScript()->registerScript(__FILE__ . '#one', $js, CClientScript::POS_HEAD);