CHtml::link and javascript variable


how can I pass a javascript variable into CHtml::link object please?

<script type="text/javascript">

var jsVariable1 = "someText";

var jsVariable2 = 25;

var test = '<?php echo CHtml::link(jsVariable1, array('controller/action','param1'=> jsVariable2)); ?>';





You have to understand one thing… the PHP code is evaluated at the moment when this code is rendered… JS code is evaluatd at the client at the moment that this function is executed… so even if there would be a way… it wouldnot work like you would like it becasue PHP is run before the JS code and at that time the JS variable has no value (in fact it does not exist yet)…

Similar question…

So how could I put the id of my checked row in a link like :

<?php echo CHtml::link('update row',array('/elements/update','id'=>'js:function(){$.fn.yiiGridView.getSelection("elements-grid")}'));?>

knowing that in my view I have something like :


array('class' => 'CCheckBoxColumn',


or there is another way to do it ?