How to create a simple “5 Star Rating”

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

Rate this:

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

Rate this:

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

Rate this:

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

Rate this:

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

Rate this: