ItGo.me Focus on IT Recommend

Home > change function not working in cakephp

change function not working in cakephp

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址https://www.aliyun.com/minisite/goods

I have this code

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

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
2

---Accepted---Accepted---Accepted---

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----------------------------