How do I add a hint to the HTML select

Source: Internet
Author: User
Select <Html>
<Head>
<script language= "JavaScript" >
<!--
Define Select original value
var Oldvalue,oldtext;
Select the onkeydown event for the Drop-down box to modify the value of the Drop-down box
function Catch_keydown (SEL)
{
Switch (Event.keycode)
{
Case 13://Enter
Event.returnvalue = false;
Break
Case://esc Key
Sel.options[sel.selectedindex].text = OldText;
Sel.options[sel.selectedindex].value = OldValue;
Event.returnvalue = false;
Break
Case 8://Empty Bar once
var s = sel.options[sel.selectedindex].text;
s = s.substr (0,s.length-1);
if (Sel.options[sel.selectedindex].value==sel.options[sel.selectedindex].text)
{
Sel.options[sel.selectedindex].value=s;
Sel.options[sel.selectedindex].text=s;
}
Event.returnvalue = false;
Break
}
if (!event.returnvalue && sel.onchange)
Sel.onchange (SEL)
}

Select the onkeypress event for the Drop-down box to modify the value of the Drop-down box
function Catch_press (SEL) {
if (sel.selectedindex>=0) {
var s = sel.options[sel.selectedindex].text + String.fromCharCode (event.keycode);
if (Sel.options[sel.selectedindex].value==sel.options[sel.selectedindex].text)
{
Sel.options[sel.selectedindex].value=s;
Sel.options[sel.selectedindex].text=s;
}
Event.returnvalue = false;
if (!event.returnvalue && sel.onchange)
Sel.onchange (SEL)
}
}

Select the onfocus event of the Drop-down box to save the original value of the dropdown box
function Catch_focus (SEL) {
OldText = Sel.options[sel.selectedindex].value;
OldValue = Sel.options[sel.selectedindex].value;
}

Restores the currently selected value of the Select Drop-down list
function Loadselect (obj,value)
{
for (var i=0; i< obj.options.length; i++)
if (Obj.options[i].value = = value)
{
Obj.selectedindex = i;
Break
}
}

Select selection box prompts for selection when the mouse moves up
function Selmouseover (obj)
{
With (Document.all.div_hint)
{
innertext = Obj.options[obj.selectedindex].text;
if (Innertext.length > 0)
{
InnerText = "" + innertext + "";
Style.display = "block";
Style.left = Event.clientx + 16;
Style.top = Event.clienty;
}
}
}

Select selection box disappears when mouse moves away
function Selmouseout (obj)
{
With (Document.all.div_hint)
{
Style.display = "None"
}
}
-->
</SCRIPT>
</Head>
<Body>
<!--call-->
<select style= ' width:130px;z-index:-1 ' name= ' Tmpsel ' Onmouseover=selmouseover (this) onmouseout=selmouseout (this ) Onkeydown=catch_keydown (This) onkeypress=catch_press (a) Onfocus=catch_focus (this) >
<option value= ' ' ></option>
</select>

<!--tip block-->
<div id=div_hint style= "Font-size:12px;color:red;display:none;position:absolute; Z-index:2; Top:200;background-color: #F7F7F7; Layer-background-color: #0099FF; border:1px #9c9c9c Solid;filter:alpha (style=0,opacity=80,finishopacity=100); ></div>
</Body>
</Html>

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.