Demo Here
<embed height="250" width="280" flashvars="file=http://content.longtailvideo.com/videos/flvplayer.flv&stretching=fill&duration=27&image=http://content.longtailvideo.com/videos/flvplayer.jpg&" wmode="opaque" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#ffffff" name="bannerswf" id="bannerswf" style="" src="http://player.longtailvideo.com/player.swf" type="application/x-shockwave-flash"/>
you can find more info on http://www.longtailvideo.com/players/jw-flv-player/
Thursday, April 30, 2009
Tuesday, April 28, 2009
how to disable button using javascript
Here is a small example of disable button after clicking on it.
<form name="form1" method="post">
<input type="text" value="Enter value" name="txt1" />
<input type="button" onclick="this.disabled=true" value="CLICK ME" />
</form>
SOURCE CODE
<form name="form1" method="post">
<input type="text" value="Enter value" name="txt1" />
<input type="button" onclick="this.disabled=true" value="CLICK ME" />
</form>
Saturday, April 11, 2009
maximum word limit for textarea
<textarea rows="8" cols="28" onKeyUp="checkWordLen(this,200);"></textarea>
TOTAL WORDS : <span id="word_counter" style="color:#FF0000;">0/200</span>
function checkWordLen(obj,MaxLen)
{
var len = obj.value.split(/[\s]+/);
counter = len.length-1;
document.getElementById('word_counter').innerHTML = counter+"/"+MaxLen;
if(len.length > MaxLen)
{
objvalue = obj.value.split(/[\s]+/);
var newval = '';
for(var m=0; m<MaxLen; m++)
{
newval+=objvalue[m]+' ';
}
obj.value='';
obj.value=newval;
return false;
}
return true;
}
TOTAL WORDS : <span id="word_counter" style="color:#FF0000;">0/200</span>
function checkWordLen(obj,MaxLen)
{
var len = obj.value.split(/[\s]+/);
counter = len.length-1;
document.getElementById('word_counter').innerHTML = counter+"/"+MaxLen;
if(len.length > MaxLen)
{
objvalue = obj.value.split(/[\s]+/);
var newval = '';
for(var m=0; m<MaxLen; m++)
{
newval+=objvalue[m]+' ';
}
obj.value='';
obj.value=newval;
return false;
}
return true;
}
Friday, April 10, 2009
how to encode and decode string in php
function base64url_encode($plainText) {
$base64 = base64_encode($plainText);
$base64url = strtr($base64, '+/=', '-_,');
return $base64url;
}
function base64url_decode($plainText) {
$base64url = strtr($plainText, '-_,', '+/=');
$base64 = base64_decode($base64url);
return $base64;
}
$base64 = base64_encode($plainText);
$base64url = strtr($base64, '+/=', '-_,');
return $base64url;
}
function base64url_decode($plainText) {
$base64url = strtr($plainText, '-_,', '+/=');
$base64 = base64_decode($base64url);
return $base64;
}
large size file upload problem in php
If you find such problem just follow the below step :
1) make a file phpinfo.php and put this code <? echo phpinfo(); ?> save it. and run to see the out put.
2) you will see your install php version information. check your php.ini file path. normally this will find at top
3) open php.ini and modify 2 lines
4) post_max_size = 8M to 100M or you want to upload max size
5) upload_max_filesize = 8M to 100M or you want to upload max size
6) save it. restart wamp and that you have done
1) make a file phpinfo.php and put this code <? echo phpinfo(); ?> save it. and run to see the out put.
2) you will see your install php version information. check your php.ini file path. normally this will find at top
3) open php.ini and modify 2 lines
4) post_max_size = 8M to 100M or you want to upload max size
5) upload_max_filesize = 8M to 100M or you want to upload max size
6) save it. restart wamp and that you have done
Add dynamic element in javascript
function appendElement()
{
node = document.getElementById('main_div'); // Parent element
tag = "div"; // Your element type
id = "div1"; // element id
html = "<table> <tr> <td> DATA <td> <tr> <table>";
var ne = document.createElement(tag);
if(id) ne.id = id;
if(html) ne.innerHTML = html;
node.appendChild(ne);
}
{
node = document.getElementById('main_div'); // Parent element
tag = "div"; // Your element type
id = "div1"; // element id
html = "<table> <tr> <td> DATA <td> <tr> <table>";
var ne = document.createElement(tag);
if(id) ne.id = id;
if(html) ne.innerHTML = html;
node.appendChild(ne);
}
Thursday, April 9, 2009
find and replace in php
$text = "Google and Yahoo is popular website";
$trans = array("Google" => "REPLACE_GOOGLE", "Yahoo" => "REPLACE_YAHOO");
$output = strtr($text, $trans);
echo $output;
$trans = array("Google" => "REPLACE_GOOGLE", "Yahoo" => "REPLACE_YAHOO");
$output = strtr($text, $trans);
echo $output;
Monday, April 6, 2009
how to allowed only limited tags in textarea or filtering tags
In this example only 'paragraph' and 'div' tag will be allowed rest of tags will be removed by function
echo strip_tags_attributes($content,'<p><div>','class');
// More details found on www.php.net
function strip_tags_attributes($string,$allowtags=NULL,$allowattributes=NULL)
{
if($allowattributes){
if(!is_array($allowattributes))
$allowattributes = explode(",",$allowattributes);
if(is_array($allowattributes))
$allowattributes = implode("|",$allowattributes);
$rep = '/([^>]*) ('.$allowattributes.')(=)(\'.*\'|".*")/i';
$string = preg_replace($rep, '$1 $2_-_-$4', $string);
}
if(preg_match('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i',$string) > 0){
$string = preg_replace('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i', '$1$4', $string);
}
$rep = '/([^>]*) ('.$allowattributes.')(_-_-)(\'.*\'|".*")/i';
if($allowattributes)
$string = preg_replace($rep, '$1 $2=$4', $string);
return strip_tags($string,$allowtags);
}
echo strip_tags_attributes($content,'<p><div>','class');
// More details found on www.php.net
function strip_tags_attributes($string,$allowtags=NULL,$allowattributes=NULL)
{
if($allowattributes){
if(!is_array($allowattributes))
$allowattributes = explode(",",$allowattributes);
if(is_array($allowattributes))
$allowattributes = implode("|",$allowattributes);
$rep = '/([^>]*) ('.$allowattributes.')(=)(\'.*\'|".*")/i';
$string = preg_replace($rep, '$1 $2_-_-$4', $string);
}
if(preg_match('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i',$string) > 0){
$string = preg_replace('/([^>]*) (.*)(=\'.*\'|=".*")(.*)/i', '$1$4', $string);
}
$rep = '/([^>]*) ('.$allowattributes.')(_-_-)(\'.*\'|".*")/i';
if($allowattributes)
$string = preg_replace($rep, '$1 $2=$4', $string);
return strip_tags($string,$allowtags);
}
How to get Google Page Rank
echo GetGoogleRank("http://www.yoursitename.com");
function GetGoogleRank($uri) {
// check Google - some systems workaround
$uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri));
$url = 'http://pagerank.4free.pl/pr.php?url=' . urlencode($uri);
$v = file_get_contents($url);
preg_match('/wynosi (.*?) z 10/si',$v,$r);
$value = $r[1];
return $value;
}
function GetGoogleRank($uri) {
// check Google - some systems workaround
$uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri));
$url = 'http://pagerank.4free.pl/pr.php?url=' . urlencode($uri);
$v = file_get_contents($url);
preg_match('/wynosi (.*?) z 10/si',$v,$r);
$value = $r[1];
return $value;
}
How to divide table in dynamic colom
Here is code to solve the problem :
$list = 100; // Total listing data here you can get it as count($your_array)
$max_td = 4; // Set this for maximum colomn you want in table
$table_width = "650"; // set table width in pixel
$td_width = $table_width/$max_td; // do not modify
if($list>0)
{
echo '<table width="'.$table_width.'" border="1" cellpadding="3" cellspacing="3">';
echo '<tr>';
for($i=1; $i<=count($list); $i++)
{
echo '<td width="'.$td_width.'"> '.$i.' </td>';
if($i%$max_td==0)
{
echo '</tr> <tr>';
}
}
echo '</table>';
} // end of IF
Labels:
html table
Subscribe to:
Posts (Atom)