function clearFormTextElements(Form)
{
if( typeof( Form ) == "object" )
{
for(var i = 0; i < Form.elements.length; i ++ )
{
if( Form.elements[i].type == "text" )
Form.elements[i].value = "" ;
else
Form.elements[i].selectedIndex=-1;
}
}
}
Analog Clock
fCol='white';document.write('div Style="position:absolute;top:0px;left:0px">
sCol='FF00FF';
mCol='red';
hCol='green';
Ybase=50;
Xbase=50;
H='...';
H=H.split('');
M='... ';
M=M.split('');
S='....';
S=S.split('');
NS4=(document.layers);
NS6=(document.getElementById&&!document.all);
IE4=(document.all);
Ypos=0;
Xpos=0;
dots=12;
Split=360/dots;
for (i=1; i less than dots+1; i++){
document.write('div id="ieDigits" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial;font-size:10px;color:'+fCol+';text-align:center;padding-top:10px">'+i+'
}
document.write('/div>')
document.write('div style="position:absolute;top:0px;left:0px">
');
for (i=0; i less than M.length; i++){
document.write('div id=y style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'">
');for (i=0; i less than M.length; i++){
document.write('div id=y style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'">
}
document.write('/div>')
document.write('div style="position:absolute;top:0px;left:0px">
');
for (i=0; i less than H.length; i++){
document.write('div id=z style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'">
');for (i=0; i less than H.length; i++){
document.write('div id=z style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'">
}
document.write('/div>')
document.write('div style="position:absolute;top:0px;left:0px">
');
for (i=0; i less than S.length; i++){
document.write('div id=x style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'">
');for (i=0; i less than S.length; i++){
document.write('div id=x style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'">
}
document.write('/div>')
function clock(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;
if (IE4){
Ypos=document.body.scrollTop+window.document.body.clientHeight-Ybase-20;
Xpos=document.body.scrollLeft+window.document.body.clientWidth-Xbase-20;
for (i=0; i < dots; ++i){
ieDigits[i].style.pixelTop=Ypos-15+Ybase*Math.sin(-1.045 +i *Split*Math.PI/180)
ieDigits[i].style.pixelLeft=Xpos-15+Xbase*Math.cos(-1.045 +i *Split*Math.PI/180)
}
for (i=0; i < S.length; i++){
x[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(sec);
x[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(sec);
}
for (i=0; i < M.length; i++){
y[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(min);
y[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(min);
}
for (i=0; i < H.length; i++){
z[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(hrs);
z[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(hrs);
}
}
setTimeout('clock()',100);
}
clock();
How to Select all checkbox in CheckboxList ?
function selectall()
{
for (var i=1; i< document.forms(0).length; i++)
{
if(document.forms(0).elements[i].id )
{
if(document.forms(0).elements[i].id.indexOf("CheckBoxList1")!=-1)
{
document.forms(0).elements[i].checked=true;
}
}
}
}
How to DeSelect all checkbox in CheckboxList using Javascript?
function deselectall()
{
for (var i=1; i< document.forms(0).length; i++)
{
if(document.forms(0).elements[i].id )
{
if(document.forms(0).elements[i].id.indexOf("CheckBoxList1")!=-1)
{
document.forms(0).elements[i].checked=false;
}
}
}
}
Amount Field Validation
function fnCurrency(pCtlTextBox)
{
var pNumKeyCode = window.event.keyCode;
var pStrValue = pCtlTextBox.value;
var pNumLength = pStrValue.length - 1;
var pNumDeciPosi = pStrValue.indexOf(".");
if (pNumLength < 0 && pNumKeyCode == 46)
{ alert("Period Not allowed In First Position.");
window.event.keyCode = 0;
}
else if (pNumDeciPosi > 0 && pNumDeciPosi+2 == pNumLength)
{
alert("After Period Only Two Numbers are Allowed.");
window.event.keyCode = 0;
}
else if(pNumKeyCode > 47 && pNumKeyCode < 58)
{
window.event.keyCode = pNumKeyCode;
}
else if(pNumKeyCode == 46 && pNumDeciPosi < 0)
{
window.event.keyCode = pNumKeyCode;
}
else
{
alert("Only numeric values allowed.");
window.event.keyCode = 0;
}
}
No comments:
Post a Comment