Ajax+php Learning and practicing the second instance _php tutorial

Source: Internet
Author: User
Effect 1. When the mouse is placed on a certain day, if there is a memo on the day, it will be displayed, such as:

Copy CodeThe code is as follows:
function Checkfortasks (Thedate, E) {
Find the Taskbox corresponding setting in the page to be visible
Theobject = document.getElementById ("Taskbox");
theObject.style.visibility = "visible";
Initialize the Taskbox location
var posx = 0;
var posy = 0;
Positioning the Taskbox position as the mouse position
POSX = E.clientx + document.body.scrollLeft;
Posy = E.clienty + document.body.scrollTop;
TheObject.style.left = posx + "px";
TheObject.style.top = posy + "px";
Set PHP Request page
Serverpage = "taskchecker.php?thedate=" + thedate;
Set PHP return Data replacement location
ObjID = "Taskbox";
var obj = document.getElementById (ObjID);
Send the request and load the returned data
Xmlhttp.open ("GET", serverpage);
Xmlhttp.onreadystatechange = function () {
if (xmlhttp.readystate = = 4 && xmlhttp.status = = 200) {
obj.innerhtml = Xmlhttp.responsetext;
}
}
Xmlhttp.send (NULL);
}

Effect 2. When the mouse clicks on a date to enter a name, the system automatically retrieves whether the name exists, and can choose to fill in the Name box,

Copy CodeThe code is as follows:
Function AutoComplete (Thevalue, E) {
Locate the location of the Autocompletediv (the label that displays the retrieved name) in the page
Theobject = document.getElementById ("Autocompletediv");
Set to visible
theObject.style.visibility = "visible";
TheObject.style.width = "152px";
Set the search label location
var posx = 0;
var posy = 0;

Posx = (Findposx (document.getElementById ("yourname") + 1);
Posy = (Findposy (document.getElementById ("yourname") + 23);

TheObject.style.left = posx + "px";
TheObject.style.top = posy + "px";
Setting Events for keyboard entry
var Theextrachar = E.which;

if (Theextrachar = = undefined) {
Theextrachar = E.keycode;
}
Set Load Search list location
var ObjID = "Autocompletediv";

Set the PHP request page and pass the user's input name to the past (taking into account the backspace effect)
if (Theextrachar = = 8) {
if (thevalue.length = = 1) {
var serverpage = "autocomp.php";
}
else{
var serverpage = "autocomp.php" + "sstring=" + thevalue.substr (0, (thevalue.length-1));
}
}
else{
var serverpage = "autocomp.php" + "sstring=" + thevalue + string.fromcharcode (Theextrachar);
}
Send the request and load the returned data
var obj = document.getElementById (ObjID);
Xmlhttp.open ("GET", serverpage);
Xmlhttp.onreadystatechange = function () {
if (xmlhttp.readystate = = 4 && xmlhttp.status = = 200) {
obj.innerhtml = Xmlhttp.responsetext;
}
}
Xmlhttp.send (NULL);
}

File package Download

http://www.bkjia.com/PHPjc/320812.html www.bkjia.com true http://www.bkjia.com/PHPjc/320812.html techarticle effect 1. When the mouse is placed on a certain day, if there is a memo on that day, it will be displayed, such as: Copy code code as follows: function Checkfortasks (Thedate, E) {//Find page ...

  • 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.