Friday, July 27, 2012

how to get past date in php

<?php // get past 15 days date  in php

$d1=date('Y-m-d'strtotime('-15 days')); 



date('Y-m-d'strtotime('-15 months')); 

//$d1=date('Y-m-d'strtotime('-20 year')); 


// next 15 days date in php

$d1=date('Y-m-d', strtotime('15 days'));


 $date = "2012-10-10";
$newdate = strtotime ( '-10 days' , strtotime ( $date ) ) ;
$newdate = date ( 'Y-m-d' , $newdate );

echo $newdate;

?>

Wednesday, July 25, 2012

how to execute php code in html

1. create   .htaccess  file and write code 

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html




this file in htdocs or WWW folder and create your html page and write php code 


in html file


Example :


myfolder
   .htaccess
   demo.html


in demo.html


<?php echo "My Name is rajeev "; ?>

Tuesday, July 24, 2012

unicode of rupees symbol


Unicode of rupee symbol  

&#x20b9; 

Monday, July 23, 2012

get all value of drop down list





<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function getalloption(){
arr=$('#ddlname option')

for(i=0; i< arr.length; i++){
alert($(arr[i]).val());
alert($(arr[i]).text());

 }



}

</script>
<select name="ddlnane" id="ddlname" >
<option value="1"> One </option>
<option value="2"> Two </option>
<option value="3"> Three </option>
<option value="4"> Fore </option>
<option value="5"> Five </option>
</select>
<input type="button" onclick="getalloption();" value="getOption"  />

Thursday, July 19, 2012

url encryption and decryption in php

<?php
$ide=5 ;
$id= base64_encode($ide);  // convert to NQ==

echo base64_decode($id); ?> // output  5

Thursday, July 12, 2012

remove leading zeros in javascript

Mobile No(beginning With Zero ) :


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function removeZero(s) {
  while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,500); }
  return s;
}

function removeFirstZero(){
alert("orisinal value : "+$('#txtmobile').val());
var mob=removeZero($('#txtmobile').val());
alert("After remove Zero :  "+mob);

$('#txtmobile').focus();
return false ;

}
</script>
 Mobile No(beginning  With Zero ) :
 <input type="text" name="txtmobile" id="txtmobile"   style="width:300px"  class="required"/>
<input type="submit" name="btnsubmite" class="myButton" onclick="return removeFirstZero();" id="btnsubmite" value=" Get Value "/>






Tuesday, July 10, 2012

how to get all options of a select using javascript




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script>
function getalllist(){
var len = document.addform.ddllist.length;  // alert(len);
var txt ='' ; // alert(len);
var values='';
arr=$("#ddllist option");
for(var i = 0; i < len ; i++) {
values+=document.addform.ddllist.options[i].value +"------" ; // form name  select box name
txt+=document.addform.ddllist.options[i].text +"------" ;
}
alert("All Values : "+ values);

alert("All Text Values : "+ txt);
}
</script>


<form   name="addform" method="post" action="#" id="addform">
<select multiple="multiple" name="ddllist" id="ddllist" >
<option value="php">PHP </option>
<option value="js">JAVASCRIPT </option>
<option value="css">CSS </option>
<option value="sql">MYSQL </option>

</select>

<input type="button" name="getvalue" value="ALL VALUE" onClick="getalllist();" />


</form>

Friday, July 6, 2012

jquery check only one checkbox


 

how to check only one checkbox in gridview
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


<script language="javascript">
function checkOnly(x)
  {
  $('.checkbox').attr("checked", false);
    $(x).attr("checked", true);
  }      
</script>
</head>

<body>
<form >
<input type="checkbox" name="cb1" value="1" class="checkbox" onclick="checkOnly(this)">
<input type="checkbox" name="cb2" value="1" class="checkbox"  onclick="checkOnly(this)">
<input type="checkbox" name="cb3" value="1" class="checkbox"  onclick="checkOnly(this)">
</form>





how to prevent enter key submitting form


Name :
Emai :

<script>

 $(document).keypress(function(e) {
            if (e.which == 13) {
            var $targ = $(e.target);

            if (!$targ.is("textarea") && !$targ.is(":button,:submit")) {
                var focusNext = false;
                $(this).find(":input:visible:not([disabled],[readonly]), a").each(function() {
                    if (this === e.target) {
                        focusNext = true;
                    }
                    else if (focusNext) {
                        $(this).focus();
                        return false;
                    }
                });

                return false;
            }
        }
    });
 </script>

Thursday, July 5, 2012

php string to javascript array




<?php  $str="RAJEEV~@~DHAR~@~DWIVEDI";   ?>
<script>
function getarray(x){
var str="<?php echo $str ; ?> ";
var arr=str.split('~@~');

alert(arr[0]); alert(arr[1]); alert(arr[2]);
}
</script>
<input type="button" value="getarray" name="GET ARRAY" onclick="getarray();"  />

Wednesday, July 4, 2012

How to php convert associative array to indexed array in PHP

get index  of array in php
<?php
$arr
=array('index1' =>'value1' "index2" =>'value2' "index3"=>'value3'); 


$ar=array_values($arr); // convert to indexing  array 


$key=array_keys($arr); // get index name 


for($i=0$icount($ar) ; $i++){
echo 
$key[$i]."=".$ar[$i]."<br> ";
}
 
?>

output

index1=value1
index2=value2
index3=value3

Sunday, July 1, 2012

shortcut key for internet

1. how to clear all history bookmark from firefox

 Press Ctrl+Shift+Del