Rectangle 27 0

You would create the file in webroot/js. I will use menu_match.js as an example. The code inside should be formatted like the following (essentially the same, except you need to name the function however you will call it later).

function menu_match()
{
   if(this.value.match('Convegni')) {
     document.getElementById('menu3').style.display = 'block'; } 
   else { document.getElementById('menu3').style.display = 'none';
}

Then in your view you will need to include a link to this js file:

<?php echo($javascript->link("des_toggle_gen_drug.js")); ?>

and then you'll need to change your select to reference the function instead of the actual code.

<select onchange="return menu_match()"   .....   </select>

I tried, but it's not working...

you may need 'return true;' at the very end of the function.

Tried it too, but it's not changing

Try putting an alert('test'); before the if, alert('if'); in the if statement, and an alert(else); in the else statement. This will tell you if your even making it into the function.

javascript - Include js in cakephp in

Rectangle 27 0

a) you shouldnt use $javascript anymore. it would be $this->Javascript

b) javascript itself is deprecated (see the documentation)

$this->Html->script()

thank you mark..i tried all ways and your suggestion but the slide not work also

how to include javascript in cakephp 1.3? - Stack Overflow

cakephp cakephp-1.3 cakephp-1.2
Rectangle 27 0

my guess: mod_rewrite not on or some other wrong config setting

How to include a JavaScript file in CakePHP 2.0 - Stack Overflow

javascript cakephp include
Rectangle 27 0

You have false in quotes, so PHP is treating it as a string and not a boolean. It should be:

echo $this->Html->script('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', array('inline' => false));

javascript - CakePHP: Include js file in header from view - Stack Over...

javascript php jquery cakephp
Rectangle 27 0

I don't use the helper at all. Not in Rails, not in CakePHP. I've never cared much for server-side technologies writing my client-side code. I'd much rather include the libraries (I do use Cake's HTML helper for this) and write the javascript/jQuery code myself. Maybe I'm a control freak, but I feel like it gives me a better handle on what's going on under the hood.

+1 These code generating helpers often do just enough to make a demo work, but usually not enough to be useful for what you actually want to do. And if you're using jQuery anyway, it's just as simple to write the code yourself.

I uses a modified ajax helper that allows me to use the cake ajax calls with jQuery. It's fantastic!

Why use CakePhp AJAX helper instead of jQuery? - Stack Overflow

jquery ajax cakephp helper
Rectangle 27 0

I'd want to expand and mention a couple of things on this.

This will print out the script tag inline which isn't always desired.

This will place the script where ever you placed $this->fetch('script') in your layout file, usually in the head of your page. (As pointed out by ub3rst4r you were passing false as a string)

This might be a much more useful version for many people, you can place a script block in any layout file (as many as you wish actually). I'll show you an example and call it scriptBottom to go before the end of my body.

<?php echo $this->fetch('scriptBottom'); ?>

Then you can pass the block to the script method like such

<?php echo $this->Html->script('script.name', array('block' => 'scriptBottom')); ?>

Yes, it does help. Thanks. I find the CakePHP book a little weak in this area.

javascript - CakePHP: Include js file in header from view - Stack Over...

javascript php jquery cakephp
Rectangle 27 0

Have you created a file called "vote.js" in your app/webroot/js folder?

Ok, that's it. Thanks!! By the way. Why it takes it from webroot?? Should i put there all my css and js files? Why doesn't it take it from js folder, or lib..

How to include a JavaScript file in CakePHP 2.0 - Stack Overflow

javascript cakephp include
Rectangle 27 0

No this is not possible. It should be obvious that pdf is a binary format and your view is generating that file. You can't use javascript inside a pdf document. You'll have to come up with your own render method to render whatever you want on top of the images inside your pdf.

php - TCPDF, cant include external javascript files in cakephp - Stack...

javascript php jquery cakephp tcpdf
Rectangle 27 0

Personally, I would consider migrating to CakePHP 1.3, as the new JS helper has full jQuery support, so you wouldn't need to include 2 separate javascript libraries, which is going to always cause you headaches down the line when you use plugins and code samples, as well as slowing down page load times.

prototypejs - Suggestions/Advice about conflicts on jQuery and Prototy...

jquery prototypejs cakephp-1.2
Rectangle 27 0

just put this in your view ctp file. :)

<?php echo $this->Html->script('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'); ?>

javascript - CakePHP: Include js file in header from view - Stack Over...

javascript php jquery cakephp
Rectangle 27 0

Why are u going on lot of attributes ?? simply use url

echo $this->Html->script('http://code.jquery.com/jquery.min.js');

Using this in the view is going to print it inline, the view will be outside the head tag, OP does not want this.

javascript - CakePHP: Include js file in header from view - Stack Over...

javascript php jquery cakephp
Rectangle 27 0

This is what I did to get e Jquery Slider working on a Cake generated page default.ctp:

I dropped my js files in webroot/js/libs and css files in webroot/css - NOTE: That the .js and .css extensions are left off.

<?php
 echo $this->Html->css('royalslider', null, array('inline' => true));
 echo $this->Html->css('royalslider-skins/default/default', null, array('inline' => true);
 echo $this->Javascript->link('libs/jquery-1.6.2.min', true);
 echo $this->Javascript->link('libs/jquery.easing.1.3.min', true);
 echo $this->Javascript->link('libs/royal-slider-7.9.min', true);
 echo $scripts_for_layout;
endif;
?>

I put the slider HTML somewhere in the body

I put the Slider Javascript: script type="text/javascript" right before the closing /body tag..

how to include javascript in cakephp 1.3? - Stack Overflow

cakephp cakephp-1.3 cakephp-1.2
Rectangle 27 0

How to include JavaScript (JS) in CakePHP ?

<?php
/**
 * Controller for paginated data from the SomeData model.
 *
 * This file will render views from views/pages/
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
App::uses('AppController', 'Controller');

/**
 * Static content controller
 *
 * Override this controller by placing a copy in controllers directory of an application
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
 */
class PagesController extends AppController {

/**
 * Controller name
 *
 * @var string
 */
  public $name = 'Pages';
  
/**
 * Displays a view
 *
 * @param mixed What page to display
 * @return void
 */
	public function display() {
		$path = func_get_args();

		$count = count($path);
		if (!$count) {
			$this->redirect('/');
		}

		$page = $subpage = $title_for_layout = null;

		if (!empty($path[0])) {
			$page = $path[0];
		}

		if (!empty($path[1])) {
			$subpage = $path[1];
		}

		if (!empty($path[$count - 1])) {
			$title_for_layout = Inflector::humanize($path[$count - 1]);
		}
    $this->render('index');
	}
}
CakePHP PHP