Senin, 06 Januari 2014

'Console' is Undefined Error for Internet Explorer

Beberapa waktu lalu disuruh mbenerin bug dari suatu aplikasi dikantor. Berhubung programmer yang bikin udah caw alias minggat, alias resign jadilah dilimpahkan ke saya. hehe ya gtu deh kerjaan saya sekarang, lebih banyak suruh mbenerin bug dan nambah fitur dari pada bikin baru. 

oke langsung aja, problemnya ada satu javascript yang error 'Console' is Undefined Error for Internet Explorer ketika dijalankan di IE. tapi di browser2 lain gak ada masalah. setelah gugling iseng2 nemulah disini.
Intinya tambahkan kode berikut pada bagian atas halaman :

if (!window.console) console = {log: function() {}};

kode tersebut berfungsi untuk mengecek apakah ada console yang telah diset, kalo enggak maka kode tersebut akan menset kedalam sebuah objek berupa fungsi kosong yang disebut log. dengan cara ini window.console tidak pernah benar2 terdefinisi. 

ya kira2 begitu, cukup sekian dan terima kasih.
si yu babay :p

Jumat, 12 Juli 2013

Examples for pager_query()

Syntax :
pager_query($query, $limit = 10, $element = 0, $count_query = NULL)

Table format Pager :
 if you want to display the data as a table format, you can use the following example:
/**To get the records, first we need to have a query for total records. I am taking an example of node table records.**/
$sql_count = "SELECT count(*) FROM node";
 $sql = pager_query("SELECT * FROM node",5,0,$sql_count); //5 - limited pages to show
 $nodeContent = array();
 while($row = db_fetch_object($sql)){
    $createdDate = date('jS M, Y',$row->created);
    $nodeContent[] = array( $row->nid, $row->title, $createdDate);
 }
 // to set the table header titles
 $tableHeader = array('Nid','Title','Date');
 // to get the table format
 $output .= theme('table', $tableHeader, $nodeContent);
 // get the pager
 $output .= theme('pager', NULL, 5, 0);
 return $output;
- from here : http://www.drup-all.com/blog/examples-pagerquery