Here we go for a simple 5 star rating. Output: HTML: <div ratingamount=”5″ maxrating=”10″></div> JS: //Rating Star JS $(‘.ratingstar’).each(function(){ var ratingamount = $(this).attr(‘ratingamount’); var maxrating = $(this).attr(‘maxrating’); $(this).html(‘<a id=”rstar_1″ class=”rstar”></a>’ +'<a id=”rstar_2″ class=”rstar”></a>’ +'<a id=”rstar_3″ class=”rstar”></a>’ +'<a id=”rstar_4″ class=”rstar”></a>’ +'<a id=”rstar_5″ class=”rstar”></a>’); var perstar_value = (maxrating / 5); var k = ratingamount; for (i=1; i<=5; … Continue reading
Problem with Jquery Corner plugin at firefox 4 ?
If your jquery.corner.js is not working with firefox 4 then a small modification of your plugin can make it OK for firefox 4. Open your jquery.corner.js file. At the beginning of the code you will find some code like var style = document.createElement(‘div’).style; var moz = style[‘MozBorderRadius’] !== undefined; var webkit = style[‘WebkitBorderRadius’] !== undefined; … Continue reading
Drupal – Clear cache from module
In Drupal, if you need to clear cache from your module then you can add this code when you need to clear cache. Mostly when we create a custom FORM to add/edit/delete anything other than node, we may need to clear cache. Code: function MODULENAME_flush_cache(){ // this will clear any type of cache cache_clear_all(NULL, ‘cache_block’); … Continue reading
Create Tag Cloud from Array in PHP
Tag cloud is a popular representation in web now a days. Most of the time we use plugin or something like that to show tag cloud. If you want to create a tag cloud from an ARRAY in PHP, follow me.. Let we want to create tag cloud for ‘fruits’ of our site. and assume … Continue reading
Drupal – Adding a clolor picker with your form item.
Drupal has its own color picker system. Drupal’s Farbtastic is very easy to add a color picker with your drupal form. here is the code for your form item. drupal_add_css(‘misc/farbtastic/farbtastic.css’); drupal_add_js(‘misc/farbtastic/farbtastic.js’); $form [‘site_pagetitlecolor’] = array( ‘#type’ => ‘textfield’, ‘#title’ => t(‘Page Title Color’), ‘#default_value’ => ‘#FFF’, ‘#description’ => ‘<div id=”site_pagetitlecolor_colorpicker”></div>’, … Continue reading
Jquery – Filtering a table rows.
Here’s an useful code to filter a table with keyword. This is mostly used when we need to find some specific rows from a long table. 1. 1st of all your table must have ID, ie. <table id=”mytableid”> <thead> <tr> <th>Item 1</th> <th>Item 2</th> <th>Item 3</th> </tr> </thead> <tbody> <tr class=”odd” style=””> <td>…</td> <td>…</td> <td>…</td> … Continue reading