Beginners must have read several js functions.

Source: Internet
Author: User

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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.