Jquery automatic pop-up Layer Effect code (1/2)

Source: Internet
Author: User

<Script type = "text/Webpage effects" src = "webpage effects/jquery. autocomplete. js"> </script>

<Link rel = "stylesheet" type = "text/css tutorial" href = "js/jquery/jquery.autocomplete.css"/>

<Script type = "text/javascript">

$ (). Ready (function (){

$ ("# Level1name"). autocomplete ("levelautocompleteajaxaction. do ");

$ ("# Level2name"). autocomplete ("levelautocompleteajaxaction. do ");

$ ("# Level3name"). autocomplete ("levelautocompleteajaxaction. do ");

});

</Script>

<Input type = "text" id = "level1name"/>

<Input type = "text" id = "level2name"/>

<Input type = "text" id = "level3name"/>

$ ("# Level1name") is the id in <input type = "text" id = "level1name"/>,

Autocomplete ("levelautocompleteajaxaction. do") is the url to send and the ajax request address

A few lines of code, that's easy!

Note: to support Chinese Input, You need to modify the jquery. autocomplete. js file in a few places. Add the following code in more than 190 lines of the file:

. Bind ("input", function (){

// @ Hack by liqt: support for inputing chinese characters in firefox

Onchange (0, true );
})


Method 2: Automatic pop-up layer

// Display listbox
Function showlstbox ()
{
Var txtbox = Invalid Response Doc ument. getelementbyid ("textbox1 ");
Var lstbox = Invalid Response Doc ument. getelementbyid ("listbox1 ");
Var strinput = txtbox. value;
Var arrmatch = new array (); // string array to be matched
Var strmatch; // string that matches successfully
Arrmatch = ["1111", "aaa", "klkk1", "akl1", "2222a", "ccc", "Nanchang", "Nanchang hi-tech Zone"];
Removeall ("listbox1 ")
For (var I = 0; I <arrmatch. length; I ++)
{
Strmatch = arrmatch [I];
If (strmatch. indexof (strinput)> = 0)
{

Var opt = document. createelement ("option ");
Opt. text = arrmatch [I]. tostring ();
Opt. value = arrmatch [I];
Lstbox. add (opt );
}
}
If (lstbox. haschildnodes ())
{
Lstbox. style. display = "block"; // display
}
Else
{
Lstbox. style. display = "none"; // hide
}
}


// Remove all content from the list with the id as listid
Function removeall (listid)
{
Var lst = your own Doc ument. getelementbyid (listid );
Var length = lst. options. length;
For (var I = length; I> 0; I --)
{
Lst. options [I-1]. parentnode. removechild (lst. options [I-1]);
}
}


// Copy the selected items in The listbox to the text box
Function moveselect (){
Var txtbox = Invalid Response Doc ument. getelementbyid ("textbox1 ");
Var lstbox = Invalid Response Doc ument. getelementbyid ("listbox1 ");
Var length = lstbox. options. length;
For (var I = 0; I <length; I ++)
{
Var lstindex = lstbox. selectedindex;
If (lstindex <0)
Return;
Txtbox. value = lstbox. options [lstindex]. text;
}
// Hide listbox after copying
Lstbox. style. display = "none ";
}

1 2

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.