CHtml::link problem

Hello,

Could someone help me correcting this url please?

<?php CHtml::link(CHtml::image(Yii::app()->request->baseUrl.’/images/current_price.png’ onmouseover=“this.src=’../images/current_price2.png’” onmouseout=“this.src=’../images/current_price.png’”), array(‘dealPayments/buy’, ‘dealid’ => $model->id), array(‘onClick’ => ‘if(confirm(“Are you sure you want to do this?”)) return true;else return false;’, ‘id’ => ‘buybutton’)) ?>

This is giving me the error:

Parse error: syntax error, unexpected ‘onmouseover’ (T_STRING) xxxxx/view.php on line 246

Thank you!

Ben

the CHtml::image sintax is this:

[b]

CHtml::image(string $src, string $alt=’’, array $htmlOptions=array ())

$src string the image URL

$alt string the alternative text display

$htmlOptions array additional HTML attributes (see tag).[/b]

You should place onmouseover and onmouseout inside an array

Thank you for your help,

I will have to give it a shot tomorrow but I am not too sure about the writing… will post back here if I struggle.

Thanks,

Ben

hi

use this code




$x = CHtml::image(Yii::app()->request->baseUrl.'/images/logo.png' ,'gh',array('onmouseover'=>"this.src='../images/current_price2.png'" ,'onmouseout'=>"this.src='../images/current_price.png'"));


echo CHtml::link($x, array('seller/report/index', 'dealid' => 12), array('onClick' => 'if(confirm("Are you sure you want to do this?")) return true;else return false;', 'id' => 'buybutton'));



Thanks I will try and let you know. I would not have worked that one out to be honest…

Will post back soon. Thanks again

Thank you so much!!!

It worked, I changed a few things but very minor!

Did you write this code right out of the box??? I could not get any help in the chat room with this.

One little thing I would like to understand please, is why did you create the $X variable and pass it inside the Chtml::link, there was no other way in doing this like having the whole code into multiple array inside the Chtml::link ?

Thanks again!!!

Ben