Several js functions for beginners,
Function JugeComment (myform )//Determines whether the user name is empty and sets it to focus
{
If (document. myform. UserName. value = ""){
Alert ("your user name cannot be blank! ");
Document. myform. UserName. focus ();
Return (false );
}
If (document. myform. content. value = "")
{
Alert ("comment content cannot be blank! ");
Document. myform. content. focus ();
Return (false );
}
}
Function CheckAll (form ){//Select all functions of the check box
For (var I = 0; I <form. elements. length; I ++)
{
Var e = form. elements [I];
If (e. name! = 'Chall ')
E. checked = true // form. chkall. checked;
}
}
Function ContraSel (form ){//Cancel the check box
For (var I = 0; I <form. elements. length; I ++)
{
Var e = form. elements [I];
If (e. name! = 'Chall ')
E. checked =! E. checked;
}
}
Function bbimg (o ){//Scale down js images in proportion
Var zoom = parseInt (o. style. zoom, 10) | 100; zoom + = event. wheelDelta/12; if (zoom> 0) o. style. zoom = zoom + '% ';
Return false;
}
Function imgzoom (img, maxsize ){Scale down js images in proportion
Var a = new Image ();
A. src = img. src
If (a. width> maxsize * 4)
{
Img. style. width = maxsize;
}
Else if (a. width> = maxsize)
{
Img. style. width = Math. round (a. width * Math. floor (4 * maxsize/a. width)/4 );
}
Return false;
}