Copy a folder from one folder to multiple folders 
perl -e 'opendir DR,".";@files = grep {/tesl/} readdir DR;foreach (@files) {next if ! -d $_; print $_,"\n";$x=qq{cp -rf ~/public_html/esl-tesol-jobs/captcha/ $_/};print $x,"\n";qx{$x};} closedir DR;'

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 52 )
Change Images Slidshow in Java Script 


<html>
<head>
<script type="text/javascript">
var slideimages=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages=new Image()
slideimages.src=slideshowimages.arguments
}
}
</script>
</head>



<body>
<a href="javascript:slideshowimages();">
<img src="1.gif" name="slide" id="tuxie" border=0 width=200 height=200>
</a>
<script>

slideshowimages("1.gif","2.gif","3.gif","4.gif")
var slideshowspeed=2000
var whichlink=0
var whichimage=0
function slideit(){
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()

</script>
</body>
</html>

[ add comment ] ( 1 view )   |  permalink  |   ( 2.9 / 38 )
Show the Tip box in html using Javascript 



<script type = "text/javascript">

var TipBoxID = "TipBox";
var tip_box_id;

function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
}

function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
}

function DisplayTip(me,offX,offY,content) {
var tipO = me;
tip_box_id = document.getElementById(TipBoxID);
var x = findPosX(me);
var y = findPosY(me);
tip_box_id.style.left = String(parseInt(x + offX) + 'px');
tip_box_id.style.top = String(parseInt(y + offY) + 'px');
tip_box_id.innerHTML = content;
tip_box_id.style.display = "block";
tipO.onmouseout = HideTip;
} // function DisplayTip()

function HideTip() { tip_box_id.style.display = "none"; }
</script>

<div
id="TipBox"
style="
display:none;
position:absolute;
font-size:12px;
font-weight:bold;
font-family:verdana;
border:#72B0E6 solid 1px;
padding:15px;
color:#1A80DB;
background-color:#FFFFFF;">
</div>

<p style="margin-top:12;">

</p>

**********************

<form>
<div style="height:100px;"></div>
<span onmouseover="DisplayTip(this,25,-50,'Welcome to S2k Designs')"><a href="#">Tip Box</a></span>

</form>



[ add comment ] ( 2 views )   |  permalink  |   ( 2.9 / 34 )
TextBox Counter in Javascript 
Just copy and paste this code and view textbox counter.
<script language = "Javascript">
/**
* DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/

maxL=255;
var bName = navigator.appName;
function taLimit(taObj) {
if (taObj.value.length==maxL) return false;
return true;
}

function taCount(taObj,Cnt) {
objCnt=createObject(Cnt);
objVal=taObj.value;
if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
if (objCnt) {
if(bName == "Netscape"){
objCnt.textContent=maxL-objVal.length;}
else{objCnt.innerText=maxL-objVal.length;}
}
return true;
}
function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval("document." + objId);
else if (document.all) return eval("document.all." + objId);
else return eval("document." + objId);
}
</script>

*********************
<html>
<head>
</head>
<body>
font> Maximum Number of characters for this text box is 255.<br>
<textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="Description" rows=7 wrap="physical" cols=40>
</textarea>
<br><br>
You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining
for your description...</font>
</body>
</html>

[ add comment ]   |  permalink  |   ( 3 / 15 )
Check All CheckBox on click in Javascript 


<script language = "Javascript">


var form='frmSample' //Give the form name here

function SetChecked(val,chkName) {
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements.name==chkName) {
dml.elements.checked=val;
}
}
}

function ValidateForm(dml,chkName){
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if ((dml.elements.name==chkName) && (dml.elements.checked==1)) return true
}
alert("Please select at least one record to be deleted")
return false;
}
// -->
</script>

************************

<form name="frmSample" method="post" action="#" onSubmit="return ValidateForm(this,'chkSample')">
<div align="left">
<input type='submit' name='' value='Delete Records'>
<a href="javascript:SetChecked(1,'chkSample')"><font face="Arial, Helvetica, sans-serif" size="2">Check
All</font></a> <a href="javascript:SetChecked(0,'chkSample')"><font face="Arial, Helvetica, sans-serif" size="2">Clear
All</font></a></div><br><br>
<!--your dynamic table contents comes here (change the name chkSample everywhere if you want to) -->
<input type="checkbox" name="chkSample" value="A"> A <br>
<input type="checkbox" name="chkSample" value="B"> B <br>
<input type="checkbox" name="chkSample" value="C"> C <br>
</form>

[ add comment ]   |  permalink  |   ( 3 / 15 )
Date validation in Java Scripts 


<script language = "Javascript">

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this = 31
if (i==4 || i==6 || i==9 || i==11) {this = 30}
if (i==2) {this = 29}
}
return this
}

function isDate(dtStr){
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}

function ValidateForm(){
var dt=document.frmSample.txtDate
if (isDate(dt.value)==false){
dt.focus()
return false
}
return true
}

</script>

********************

<form name="frmSample" method="post" action="" onSubmit="return ValidateForm()">
<p>Enter a Date <font color="#CC0000"><b>(mm/dd/yyyy)</b></font>
:
<input type="text" name="txtDate" maxlength="10" size="15">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

[ add comment ]   |  permalink  |   ( 2.9 / 14 )
Count the words in a sentence using PHP 
<?php

$str = "I am the best";

echo str_word_count($str);
?>

********out put *******
4

[ add comment ] ( 1 view )   |  permalink  |   ( 2.8 / 29 )
Calculate the similarty between two string  


<?
$string1="rakesh";
$string2="rake";
$string3="rakesh";
$string4="rakesh";

similar_text($string1, $string2, $p);
similar_text($string3, $string4, $q);
echo "Percent: $p%".'<br>';
echo "Percent: $q%".'<br>';

?>

******* out put *********

Percent: 80%
Percent: 100%

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 25 )
Pad a string to a certain length with another string 


<?php
$input = "Rakesh";

echo str_pad($input, 10, "*", STR_PAD_LEFT); //pad in left side
echo str_pad($input, 10, "#", STR_PAD_BOTH); //pad in both side
echo str_pad($input, 10 , "@"); //pad in right side
?>

********output **********
****Rakesh
##Rakesh##
Rakesh@@@@


[ add comment ]   |  permalink  |   ( 3.2 / 17 )
Replace the string instead of searching string in PHP [Replace String ] 


<?php

$replace = str_replace("r", "t", "kumar");
echo $replace;
?>

**********output ********
kumat

// here r replace with t

[ add comment ] ( 1 view )   |  permalink  |   ( 3.1 / 27 )

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Next> Last>>