jquery automatic pop-up Layer effect code (1/2)

Source: Internet
Author: User

<script type= "text/web Effects" src= "Web Effects/jquery/jquery.autocomplete.js" ></script>

<link rel= "stylesheet" type= "text/css Course" 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"/>

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

AutoComplete ("Levelautocompleteajaxaction.do") requests an address for a sent Url,ajax

A few lines of code, so simple!

To support Chinese input, you need to modify the Jquery.autocomplete.js file in several places, in the file of more than 190 lines, plus the following code:

. Bind ("Input", function () {

@hack by Liqt:support to inputing Chinese characters in Firefox

onchange (0, true);
})


Method two automatic pop-up layer

Show ListBox
function Showlstbox ()
{
var txtbox = Window.document.getelementbyid ("textbox1");
var lstbox = Window.document.getelementbyid ("ListBox1");
var strinput = Txtbox.value;
var arrmatch = new Array ();//array of strings to match
var Strmatch; Match a successful string
Arrmatch = ["1111", "AAA", "Klkk1", "Akl1", "2222a", "CCC", "Nanchang", "Nanchang high-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"; Show
}
Else
{
Lstbox.style.display = "none";//Hide
}
}


Remove the contents of the list with ID Listid
function RemoveAll (Listid)
{
var lst = Window.document.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 contents of the selected item in the ListBox to the text box
function Moveselect () {
var txtbox = Window.document.getelementbyid ("textbox1");
var lstbox = Window.document.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 replication completes
Lstbox.style.display = "None";
}

Home 1 2 last 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.