Adding Javascript Into Views

Hi yii’ers,

I need help for adding javascript into my views… I try using Yii::app()->clientScript->registerScript but I don’t know how to use it for this script … please help me




<script language="JavaScript" type="text/javascript">

$(document).ready(function() {

	var gain = $('#gain')[0];

	var silenceLevel = $('#silenceLevel')[0];

	for(var i=0; i<=100; i++) {

		gain.options[gain.options.length] = new Option(100-i);

		silenceLevel.options[silenceLevel.options.length] = new Option(i);

    }

	var appWidth = 300;

	var appHeight = 200;

	var flashvars = {'event_handler': 'microphone_sync_events', 'upload_image':

	<?php echo Yii::app()->baseUrl . '/images/' ?>'usochk.png'};


	var params = {};

	var attributes = {'id': "oewewApp", 'name':  "oewewApp"};

	swfobject.embedSWF("<?php echo Yii::app()->baseUrl . '/components/js/' ?>oewew.swf", "flashcontent",

	appWidth, appHeight, "10.1.0", "", flashvars, params, attributes);

});

 

function configureMicrophone() {

  if(! Oewew.isReady) {

    return;

  }


  Oewew.configure($('#rate').val(), $('#gain').val(), $('#silenceLevel').val(), $('#silenceTimeout').val());

  Oewew.setUseEchoSuppression($('#useEchoSuppression').is(":checked"));

  Oewew.setLoopBack($('#loopBack').is(":checked"));

}


</script>



Thanks In Advances

up…up…need help

<?php

$cs = Yii::app()->clientScript;

$cs->registerScriptFile(Yii::app()->request->baseUrl .’/js/O_tableSorter.js’);

?>

In the previous post I pasted the sample script , you can do in the same way

I try your suggest but still can’t work …Mr. Kumarkulandai

can you paste your view code?

like this




<?php

$js = Yii::app()->clientScript;

$js->registerScriptFile(Yii::app()->request->baseUrl .'/js/jquery142.js');

?> 

<?php

$as = Yii::app()->clientScript;

$as->registerScriptFile(Yii::app()->request->baseUrl .'/js/swfobject.js');

?> 

<?php

$bs = Yii::app()->clientScript;

$bs->registerScriptFile(Yii::app()->request->baseUrl .'/js/recorder.js');

?> 	

<?php

$cs = Yii::app()->clientScript;

$cs->registerScriptFile(Yii::app()->request->baseUrl .'/js/owew.js');

?> 	


<style>

#control_panel { white-space: nowrap; }

#control_panel a { outline: none; display: inline-block; width: 24px; height: 24px; }

#control_panel a img { border: 0; }

#save_button { position: absolute; padding: 0; margin: 0; }

#play_button { display: inline-block; }

#count { font-size: 20px; font-weight: bold; }

</style>





<div id="status">

   Recorder Status...

  </div>


  <div id="control_panel">

  <a id="record_button" onclick="Recorder.record('audio', 'audio.wav');" href="javascript:void(0);" title="Record">

	  <img src="<?php echo Yii::app()->baseUrl . '/images/' ?>record.png" width="24" height="24" alt="Record"/></a>

  <span id="save_button">

    

  </span>

  <a id="play_button" style="display:none;" onclick="Recorder.play('audio');" href="javascript:void(0);" title="Play">

	  <img src="<?php echo Yii::app()->baseUrl . '/images/' ?>play.png" width="24" height="24" alt="Play"/></a>

  </div>


  <div id="upload_status">

  </div>


  <div id="count">

  </div>


  <form id="uploadForm" name="uploadForm" action="upload.php">

    <input name="authenticity_token" value="xxxxx" type="hidden">

    <input name="upload_file[parent_id]" value="1" type="hidden">

    <input name="format" value="json" type="hidden">

  </form>


</div>




 






<?php

$js = Yii::app()->clientScript;

$js->registerScriptFile(Yii::app()->request->baseUrl .’/js/jquery142.js’);

?>

<?php

$as = Yii::app()->clientScript;

$as->registerScriptFile(Yii::app()->request->baseUrl .’/js/swfobject.js’);

?>

<?php

$bs = Yii::app()->clientScript;

$bs->registerScriptFile(Yii::app()->request->baseUrl .’/js/recorder.js’);

?>

<?php

$cs = Yii::app()->clientScript;

$cs->registerScriptFile(Yii::app()->request->baseUrl .’/js/owew.js’);

?>

change to

<?php

$js = Yii::app()->clientScript;

$js->registerScriptFile(Yii::app()->request->baseUrl .’/js/jquery142.js’);

$js->registerScriptFile(Yii::app()->request->baseUrl .’/js/swfobject.js’);

$js->registerScriptFile(Yii::app()->request->baseUrl .’/js/recorder.js’);

$js->registerScriptFile(Yii::app()->request->baseUrl .’/js/owew.js’);

?>

I did but still can’t work… Mr. Kumar Kulandai

up…up…need help

up…up…need help

SOLVED it self

thanks to Mr. Kumar Kulandai.