Well I am trying to convert an image into an button on a page of application done in CakePHP.This is the first issue.I can not use the image as a button.After that I want a Javascript which pops up a window of the action in it...!!!How can I do this thing...can any1 tell me how to do that..!!!
For the image button I suggest you use this code:
<input type="image" src="<?php echo $html->image('image.gif'); ?> name="image" width="60" height="60">
To open the window with action inside, something like that:
<?php echo $html->link('yourlinkdescription', '#', array('onclick'=>"var openWin = window.open('".$html->url(array('action'=>'youraction')."', '_blank', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=500,height=500'); return false;")); ?>
Actually, the undocumented technique for using an image as a button is this:
<?php echo $form->end('image.gif'); ?>
Instead of the typical $form->end parameter which is the text for the button:
<?php echo $form->end('Submit'); ?>
Assuming image.gif is located at /app/webroot/img/image.gif, this will automatically create the button with that image.
For cakephp 2.7 use
<?php echo $this->Html->link(__('<button type="button" class="btn btn-icon command-delete"><span class="md md-photo-library"></span></button>'), "javascript:void(0)", array("escape" => false,"onclick"=>"window.open('".$this->Html->url(array('controller' => 'galleries', 'action' => 'index', $page['Page']['id']))."','photo','height=650,width=1000,scrollbars=yes,resizable=yes')")); ?>
or simply
<?php echo $this->Html->link(__('Photos'), "javascript:void(0)", array("onclick"=>"window.open('".$this->Html->url(array('controller' => 'galleries', 'action' => 'index', $page['Page']['id']))."','photo','height=650,width=1000')")); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With