Posts

Scroll to bottom of image when mouse over

1. Css Code <style type="text/css">             .image-bg {                 margin:0;                 padding:0;                 background-image: url("landingpage_07.jpg");                 background-repeat: no-repeat;                 display: inline-block;                 height: 344px;                 padding-top: 31px;                 position: relative;                 width: 457px;   ...

Exclude weekends on jQuery datepicker

$ ( 'yourSelector' ). datepicker ({ minDate : 0 , // your min date maxDate : '+1w' , // one week will always be 5 business day - not sure if you are including current day beforeShowDay : $ . datepicker . noWeekends // disable weekends });

Disable all Sundays in jQuery UI Calendar (datepicker)

$ ( "#datepicker" ). datepicker ({ beforeShowDay : function ( date ) { var day = date . getDay (); return [( day != 0 ), '' ]; } });

Javascript random number between two numbers

function getRandomInt(min, max) {   return Math.floor(Math.random() * (max - min)) + min; } console.log(getRandomInt(1,100));

Javascript display numbers with commas

function commaSeparated(val){     while (/(\d+)(\d{3})/.test(val.toString())){       val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');     }     return val; } // Call Function console.log(commaSeparated(1)); // 1 console.log(commaSeparated(10)); // 10 console.log(commaSeparated(100)); // 100 console.log(commaSeparated(1000)); // 1,000 console.log(commaSeparated(10000)); //10,000

PHP: show a comma on all value except last value from mysql_fetch_array

$count = 0; while ($servdescarrayrow = mysql_fetch_array($servdescarray)) { if ($count++ > 0) echo ","; echo $servdescarrayrow['serv_desc']; }

PHP: Prepend leading zero before single digit number

It will only add the zero if it's less than the required number of characters. When working with numbers, you should use %d (rather than %s ), especially when there is the potential for negative numbers. If you're only using positive numbers, either option works fine. For example: sprintf("%04s", 10); returns 1000 sprintf("%04s", -10); returns 0-10 Where as: sprintf("%04d", 10); returns 1000 sprintf("%04d", -10); returns 100 <? php $num = 4 ; $num_padded = sprintf ( "%02d" , $num ); echo $num_padded ; // returns 04 ?> You can use sprintf: http://php.net/manual/en/function.sprintf.php .