Skip to main content

Posts

Check All by jQuery

Check All by jQuery Method 1:  $(document).ready(function() {     $('#selectAll').click(function(event) {         if(this.checked) { // check select status             $('.checkbox1').each(function() {                 this.checked = true;  //select all checkboxes with class "checkbox1"                         });         }else{             $('.checkbox1').each(function() {                 this.checked = false; //deselect all checkboxes with class "checkbox1"                                 });               }     });   }); Html <div> <input type="checkbox" id="selectAll"...

Sort Table by jquery

1.  Sort table first column by jQuery Create a function sortTable. Pass table id & order function sortTable(table, order) {             var asc   = order === 'asc',             tbody = table.find('tbody');          tbody.find('tr').sort(function(a, b) {         if (asc) {             return $('td:first', a).text().localeCompare($('td:first', b).text());         } else {             return $('td:first', b).text().localeCompare($('td:first', a).text());         }     }).appendTo(tbody); } Call function when document loaded jQuery(document).ready(function() { sortTable($('#editable'),'asc'); }); 2. Sort the select option without empty value Html: <select id="contacts" class="filteroption" name="data[Candidateprofile][company]"> ...

How to add Validation rule in jQuery validation Plugin

How to add Validation rule in jQuery validation Plugin 1. Load the validate plugins <script src="js/jquery.validate.js"></script> 2. Now call the jQuery validate method <script> $(document).ready(function(){ // Add your own custom method  $("#old_password").rules('add',{remote:"check_password.php",  messages: {remote: "Passwords do not match"}});  $("#confirm_password").rules('add',{equalTo: "#password",   messages: {equalTo: "New password and confirm password do not match"}}); }); controller action $count=$this->Member->find('count',array( 'conditions'=>array('Member.password'=>md5($_GET['oldPass']), 'Member.id'=>$this->Session->read('Member.id'))));    if($count>0)    { echo 'true'; die;    } else { echo 'false'; die;   } // valid...

Bootstrap panel accordion with icons

Bootstrap panel accordion with icons HTML <div id="accordion" class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h5 class="panel-title"> <a href="#collapseOne" data-parent="#accordion" data-toggle="collapse" class="accordion-toggle">Profile</a> </h5> </div> <div class="panel-collapse collapse in" id="collapseOne"> <div class="panel-body"> <p>Hello Sudhir</p> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h5 class="panel-title"> <a href="#collapseTwo" data-parent="#accordion" data-toggle="collapse" class="accordion-toggle">Profile</a> </h5> ...

Google Analytics in Cakephp

Implementation of Google analytics in cakephp. Create a element for it. app/views/elements/google-analytics.ctp : <?php $gaCode = Configure::read('google-analytics.tracker-code'); if ($gaCode) { $googleAnalytics = <<<EOD <script type="text/javascript">   var _gaq = _gaq || [];   _gaq.push(['_setAccount', '$gaCode']);   _gaq.push(['_trackPageview']);   (function() {     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })(); </script> EOD; echo $googleAnalytics; } ?> Call the element where you want. The best place to call element in layout. <?php echo $this->element('google-analytics...

Cakephp Route

If you want like this example.com/article/show-by-day.html example.com/article/slug-post.html Shows above url in route file like this Router::connect('/article/show_by_day',array('controller' => 'posts', 'action' => 'show'), array('pass' => array('show_by_day'))); Router::connect('/article/slug-post',array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug'))); Router::connect('/article/slug-post/:slug', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug'))); if route like Router::connect('/account', array('controller' => 'clientcontacts', 'action' => 'index', 'account' => true)); then its controller function is public function account_index() { }  its view file...

Cakephp Email Setting

Basic usage First of all, you should ensure the class is loaded using App::uses(): App::uses('CakeEmail', 'Network/Email'); Using CakeEmail is similar to using EmailComponent. But instead of using attributes you use methods. Example: $Email = new CakeEmail(); $Email->from(array('me@example.com' => 'My Site')); $Email->to('you@example.com'); $Email->subject('About'); $Email->send('My message'); To enable the transport, add the following information to your Config/email.php: You can configure SSL SMTP servers such as Gmail. To do so, prefix the host with 'ssl://' and configure the port value accordingly. Example: class EmailConfig {     public $gmail = array(         'host' => 'ssl://smtp.gmail.com',         'port' => 465,         'username' => 'my@gmail.com',         'password' => 'secret',         'transport' =...