Thursday, February 28, 2013

Rotate Image using JavaScript


<script type="text/javascript">

var RotateInterval;
var Rad = 10;

function StartImgRotate()
{
RotateInterval = setInterval(start, 100);
//RotateInterval = setTimeout(function(){start();}, 10);
}

function start()
{
 document.getElementById("img").style.MozTransform = "rotate(" + Rad + "deg)";                    
 document.getElementById("img").style.webkitTransform = "rotate(" + Rad + "deg)";
 Rad += 10;
}

function StopImgRotate()
       {
clearInterval(RotateInterval);
}
</script>


<img id="img" src="icon.jpg" width="50px" height="50px" /> <br />
<br />
<input type="button" value="Play" onClick="StartImgRotate();" />
<input type="button" value="Stop" onClick="StopImgRotate();" />


Thursday, February 14, 2013

Force File for Download using Php | Download File on Click URL


1.       Upload the file you want to make available for download to your hosting Web server.
For example,
myhtml.html
2.       Create one another a new PHP file - I recommend naming it the same name as your downloaded file, only with the extension .php. For example:
myhtml.php
3.       Open the PHP block:
<?php
//  set the HTTP header:
header('Content-disposition: attachment; filename= myhtml.html');
// Then set the MIME-type of the file:
header('Content-type: application/html');
// Point to the file you want to download:
readfile('myhtml.html');
?>
4.       Link to your PHP file as a download link. For example:
<a href="myhtml.php">Download my html document </a>

Tuesday, September 25, 2012

usefull jQuery | jQuery importance

set width in percentage using jquery

<div id="IDofDiv" />
$('div#IDofDiv).width('90%'); <div id="IDofDiv" style="width: 90%;"/>

Clearing <input type='file' /> using jQuery

clear an <input type='file' /> control value with jQuery
  $("#control").replaceWith("<input type='file' id='control' />");
<input type="file" id="control" />

How to get the length of  textbox value or string using jQuery?

var myLength = $("#myTextbox").val().length;

How to check if an element has a particular class

jQuery is() is the function that checks if any of the returned DOM objects from the selector satisfies the criteria set in the argument.
if ($(#elm).is('.classname)) { //#elmement has the class } else { //#elm doesn't have the class }

Auto refresh parent window after closing popup Window | Close popup window and refresh its parent window in javascript

<script language="JavaScript">
function refreshParent()
{
 window.opener.location.href = window.opener.location.href;
 if (window.opener.progressWindow)
 {
    window.opener.progressWindow.close()
 }
  window.close();
}
</script>

PHP - Return multiple value from function

function getXYZ()
{
    return array(1,2,3);
}

list($x,$y,$z) = getXYZ();

jQuery UI Datepicker - Date Format | Date formating option for jQuery UI Date Picker

$( "#datepicker" ).datepicker( "option", "dateFormat", "mm/dd/yy");
$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd");
$( "#datepicker" ).datepicker( "option", "dateFormat", "d MM, y");
$( "#datepicker" ).datepicker( "option", "dateFormat", "DD, d MM, yy");
$( "#datepicker" ).datepicker( "option", "dateFormat", "d M, y");
$( "#datepicker" ).datepicker( "option", "dateFormat", "'day' d 'of' MM 'in the year' yy");

//if Above not work than you may also try below date formate option for jquery ui datetimepicker script
 jQuery("#txt_holiday_date").datepicker({dateFormat: 'yy-mm-dd'});


Execute Php script through curl | execute php script using curl

<?php
$url = "url of script/ code page which we want to execute using curl";
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST,0);
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  // RETURN THE CONTENTS OF THE CALL
$return = curl_exec($ch);

//write down execution code return data to txt file
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $return;
fwrite($fh, $stringData);
fclose($fh);
?>