Thursday, August 25, 2011

Get Values from Checkbox in Jquery

$('#checkBox').attr('checked');

$('#edit-checkbox-id').is(':checked');

var checked = $('input[type=checkbox]').is(':checked');

var checkbox_value = $('#check_box_id:checked').val();

$("input[@type=checkbox][@checked]").each(

function() {
   // Insert code here
   }

);

//
$("input[type=checkbox][checked]").each(

function() {
   // Insert code here
   }
);
$('input[name=foo]').is(':checked')
$('input[name=foo]').attr('checked')
$('input[name=foo]').attr('checked', true);
$('input[name=foo]').attr('checked', false);


$(document).ready(function(){

$('#submit_button').click(function() {

if (!$("input[@name='name']:checked").val()) {
   alert('Nothing is checked!');
   return false;
}

else {
   alert('One of the radio buttons is checked!');
}

});
});

Friday, July 15, 2011

AJAX Loading Icon Generators

AJAX Loading Icon Generators

If you want to inform your website\'s visitor that there are more information to be displayed or still to be loaded on your page, you may need a 'loading' or 'wait' icon. An Ajax loading icon is also most commonly used on AJAX-base sites and applications. Here, we present to you online tools that will generate an AJAX loading icons.

Preloaders.net







Thursday, July 14, 2011

Div Scrollable Contents on MouseOver On Javascript




SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE SCROLL UP AND SCROLL DOWN LINKS
SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS The top-level function, escape, encodes the string that is contained in the string argument to make it portable. A string is considered portable if it can be transmitted across any network to any computer that supports ASCII characters. We can use escape function in JavaScript to make a string portable to transmit it over a network. All the non ASCII characters are to be converted before sending them by using escape function. The escape function will replace these non ASCII characters to its two or four digit hex format.
Scroll Up Scroll Down

Here Code


<html>
<script type="text/javascript">
var scrolling = null;
var _speed = 12;


function doScrollUp()
{
var d = document.getElementById('scroller');
d.scrollTop = d.scrollTop - _speed;


scrolling = window.setTimeout(function() {
doScrollUp();
}, 100);
}


function doScrollDown()
{
var d = document.getElementById('scroller');
d.scrollTop = d.scrollTop + _speed;


scrolling = window.setTimeout(function() {
doScrollDown();
}, 100);
}


function doStopScroll()
{
window.clearTimeout(scrolling);
}
</script>
<body>
<h2>SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS</h2>
<div id="scroller" style="width:100%; height:100px; overflow:hidden;">


SCROLLABLE DIV CONTENTS WHEN MOUSE OVER THE UP AND DOWN LINKS
<br /><br /><br />
The top-level function, escape, encodes the string that is contained in <br /><br />
the string argument to make it portable. A string is considered portable <br /><br />
if it can be transmitted across any network to any computer that
supports ASCII characters.<br />
We can use escape function in JavaScript to make a string portable
to transmit it over a network. All the non ASCII characters are to be <br />
converted before sending them by using escape function. The escape function <br />
will replace these non ASCII characters to its two or four digit hex format.<br />
<br /><br /><br /><br />
</div>
<div>
<span style="color:red;" onmouseover="doScrollUp();" onmouseout="doStopScroll();" style="padding-right:10px;">Scroll Up</span>
<span style="color:blue;" onmouseover="doScrollDown();" onmouseout="doStopScroll();">Scroll Down</span>
</div>


</body>
</html>

Tuesday, July 12, 2011

Escape Function in Javascript or Jquery

Escape Function:


The escape() function encodes a string.


<script type="text/javascript">
unescape("you can pass & symbols & any other special characters through query string when you using ajax posting & jquery posting");
</script>
The top-level function, escape, encodes the string that is contained in the string argument to make it portable. A string is considered portable if it can be transmitted across any network to any computer that supports ASCII characters.
We can use escape function in JavaScript to make a string portable to transmit it over a network. All the non ASCII characters are to be converted before sending them by using escape function. The escape function will replace these non ASCII characters to its two or four digit hex format.
 The escape function converts a blank space into %20, same way it converts & to %26.



The unescape() function decodes an encoded string.


<script type="text/javascript">
unescape("you%20can%20pass%20&%20symbols &%20any%20other%20special characters%20through%20query%20string when%20you%20using%20ajax%20posting &%20jquery%20posting");
</script>

Monday, January 17, 2011

Disable copy paste and autocomplete for textbox in HTML

Disable copy paste and autocomplete for textbox in HTML

<input size="25" name="name" id="name' maxlength="20" onCopy="return false" onDrag="return false" onDrop="return false" onPaste="return false" autocomplete="off" />

Saturday, January 15, 2011

Login Screen Shaking

Shaking the Login Screen.  when u can refresh the page and submit the page....

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
          addLoadEvent = function(func){
            if (typeof jQuery!="undefined")
                jQuery(document).ready(func);
           
            else if ( typeof wpOnload!='function'){
                wpOnload=func;
            } else {
                var oldonload=wpOnload;
                wpOnload=function(){
                    oldonload();
                    func();
                }
            }
        };
       
        function s(id,pos){
            g(id).left = pos+'px';
        }
        function g(id){
            return document.getElementById(id).style;
        }
        function shake(id,a,d) {
            c=a.shift();
            s(id,c);
            if(a.length>0){
                setTimeout(function(){
                    shake(id,a,d);
                },d);
            } else {
                try {
                    g(id).position='static';
                    wp_attempt_focus();
                }
                catch(e){}
            }
        }
       
        addLoadEvent(function(){
            var p = new Array(10, 10, 10, 0, -10, -10, -10, 0);
            p = p.concat(p.concat(p));
            var i = document.forms[0].id;g(i).position='relative';
            shake(i, p, 20);
        });
  </script>


</head>
<body onload="document.getElementById('username').focus();">
<table width="90%" cellpadding="0" cellspacing="0" border="0" align="center">
   <tr>
      <td valign="top">
         <form method="post" action="" name="frmLogin" id="frmLogin">
                 <table width="50%" cellpadding="2" cellspacing="2" border="1" align="center">
                         <tr><td height="10px"></td></tr>
                          <tr>
                        <td width="40%"> USERNAME:</td>
                         <td width="60%">
                                 <input type="text" name="username" id="username" autocomplete="off" />
                      </td>
                      </tr>
                       <tr>
                       <td>PASSWORD: </td>
                      <td>
                       <input type="password" name="password" id="password" autocomplete="off" />
                   </td>
               </tr>             </table>
      </form>
  </td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
    function wp_attempt_focus(){
        setTimeout( function() {
            try {
                d = document.getElementById('username');
                d.value = '';
                d.focus();
            } catch(e){}
        }, 200);
    }
     wp_attempt_focus();
    if(typeof wpOnload == 'function')wpOnload();
  </script>

Saturday, January 8, 2011

Sort An Array of String Without Using PHP Function

To sort an array of string without using php function?

try this...

$str = array(“Z”,”c”,”A”,”C”,”E”,”B”,”M”,”N”);
$array_length = sizeof($str);

for($x = 0; $x < $array_length; $x++) {

for($y = 0; $y < $array_length; $y++) {

if(strcasecmp($str[$x],$str[$y])<0) {

$hold = $str[$x];
$str[$x] = $str[$y];
$str[$y] = $hold;
}
}
}

echo "<pre>”;
print_r($str);
echo “</pre>”;

get last day of the previous month in PHP

Get Last Day Of The Previous Month


$date = "2010-12-31";

list($yr,$mn,$dt)  = split('-', $date);         // separate year, month and date
$time_stamp        = mktime(000$mn0$yr);   // Create time stamp
$last_month_last_day = date("Y-m-t", $time_stamp);

echo "last_month : " . $last_month";
ouptut : 2010-11-30...

get last day of the current month in PHP

Get Last Day Of The Current Month


To get the last day of the month so got this piece of code.
try the following code all are different format....

date('Y-m-d', strtotime('-1 second', strtotime(date('m') . '/01/' . date('Y') . '00:00:00')))

date(“Y-m-d”,mktime(0,  0,  0, (date(‘m’) + 1), 0, date(‘Y’)))

strtotime(‘+1 month -1 second ‘ . date(‘Y’) . ’-’ . date(‘m’) . ’-01′ );

date(“Y-m-t”); //t = number of days in the month

date(“Y-m-d’,mktime(0, 0, 0,  2, 32, 2008));

date(‘t’,strtotime(“last month”));

date(‘D Y-m-t’, strtotime(“last month”))