Focus on IT Recommend

Home > change function not working in cakephp

change function not working in cakephp



I have this code

<script type="text/javascript">
    $("#category_id").change(function() {   
        alert("Thanks for clicking.");

echo $this->Form->input('category', array('id' =>'category_id',
    'options' => array('it' => 'IT',
    'contents' => 'Content writing',
    'logo' => 'Logo Designing'

when I select option from list change function doesn't work. How can I resolve this issue?

cakephp cakephp-2.3
  this question
edited Dec 19 '14 at 12:48 asked Dec 17 '14 at 8:58 Haris 69 9


2 Answers


Wrap your jquery script inside document.ready as your element doesn't exist when the script is loaded.

jQuery(document).ready(function($) {
    $("#category_id").change(function() {   
      alert("Thanks for clicking.");

  this answer
answered Dec 26 '14 at 17:30 Konsole 2,800 2 16 34


I think you have not yet include success file jquery.js in the view or layout default.ctp

Recommend:cakephp - Recursive function in a CakePhHP Component not working

is this function doesn't callback, displaying "Call to undefined function list_directory_contents()". I tried others recursive functions, same result. Althought a friend doesn't seems to have the same problem. Here is my function : `functi

  this answer
answered Dec 26 '14 at 13:56 Quy Le 670 6 10


Recommend:cakephp $this->redirect not working in function

d.. it works in other code e.g. users, but not in the events one.. THE FUNCTION DOES SAVE THE EVENT, ITS JUST IT WONT REDIRECT OR USE THE SETFLASH Here is the code for my event controller add funciton: public function add() { if ($t

------splitte line----------------------------