SharePoint list drop-down box optimization

Source: Internet
Author: User

Because the drop-down box for the SharePoint list is not searchable,

Customer experience is very bad, took a day to encapsulate the JS code, the actual following

(Automatically generate a text box above the SharePoint list, similar to the Baidu form search dropdown box content, select the drop-down box to automatically select the contents of the text box selection)

Actual code

Just add the following JS code to the list page. Add a reference, Baidu search AutoComplete can

"Hecdepartment" and "oadepartment" are the internal names of the drop-down boxes. You need to change these two to use

<script src= "Jquery-1.9.1.min.js" type= "Text/javascript" ></script>
<link href= "Jquery.autocomplete.css" rel= "stylesheet" type= "Text/css"/>
<script src= "Jquery.autocomplete.js" type= "Text/javascript" ></script>

<script type= "Text/javascript" >
$ (function () {
var selects = document.getElementsByTagName ("select");
$.each (selects, function () {
if ($ (this). attr ("title") = = "Hecdepartment")
{
$ (this). Parent (). Parent (). Parent (). Before ("<tr><td></td><td><input type=\" text\ "id=\ "Txtheckey\" style=\ "width:535px;\"/><td></tr> ");
var selvalue = []; Defines an empty array to receive all the values of select option
var select=$ (this);
var options = $ (this). Find ("option"); All option under Select
for (Var i=1;i<options.length;i++) {
Selvalue.push (Options.eq (i). text ());
}
$ (' #txtHECKey '). AutoComplete (selvalue). Result (function (event, data) {
for (Var i=1;i<options.length;i++) {
if (Options.eq (i). Text () ==data)
{
Select.val (Options.eq (i). Val ());
}
}
})

}
else if ($ (this). attr ("title") = = "Oadepartment")
{

$ (this). Parent (). Parent (). Parent (). Before ("<tr><td></td><td><input type=\" text\ "id=\ "Txtoakey\" style=\ "width:535px;\"/><td></tr> ");
var selvalue = []; Defines an empty array to receive all the values of select option
var select=$ (this);
var options = $ (this). Find ("option"); All option under Select
for (Var i=1;i<options.length;i++) {
Selvalue.push (Options.eq (i). text ());
}
$ (' #txtOAKey '). AutoComplete (selvalue). Result (function (event, data) {
for (Var i=1;i<options.length;i++) {
if (Options.eq (i). Text () ==data)
{
Select.val (Options.eq (i). Val ());
}
}
})
}
})

})
</script>

<style type= "Text/css" >
#txtKey
{width:300px;}
</style>

SharePoint list drop-down box optimization

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.