JAVASCRIPT+CSS Many websites use the star to achieve the scoring function _ form effects

Source: Internet
Author: User
The function has two parameters and functions as follows:
Obj:img the parent container of the label group, the type is a DOM object;
Oevent:event object.
The advantage of this function is that the HTML code can be very concise, the use of pictures can also be very small, only need two pictures. The event handle can only be written on the parent container of the IMG. Demo use of the picture I used is an absolute address, you use the time to change to the site's relative address on it. When we clicked, I used an alert event. In fact, we'll use an Ajax method here to upload the relevant parameters to the server side. Just write alert (this._num+1) as Sendajax (this._num+1).
Two pictures needed:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Cloud Habitat Community _www.jb51.net_" when making selected stars rating </title> <style type= "Text/css" >. starwrapper{border:1px solid #FFCC00;p adding:5px;width:70px;} . Starwrapper Img{cursor:pointer;} </style> <script type= "Text/javascript" > Function rate (obj,oevent) {//==================//Picture address settings//==== ============== var imgsrc = ' http://www.jb51.net/upload/20080508122008586.gif '; var imgsrc_2 = ' http://www.jb51.net/upload/20080508122010810.gif '; ---------------------------------------------------------------------------if (Obj.rateflag) return; var e = Oevent | | window.event; var target = E.target | | E.srcelement; var Imgarray = obj.getelementsbytagname ("img"); for (Var i=0;i <body> <p Class= "Starwrapper" onmouseover= "rate (this,event)" > </p> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.