[ASP code] a drop-down box in which visitors enter data themselves

Source: Internet
Author: User
Tags return
Access | data | dropdown

The dropdown box lists the data, and then it can be entered by the user, how do you do this?

ComboBox with Edit function

<HTML>
<HEAD>
<PUBLIC>
<component tagname= "COMBOBOX" >
<property name= "Text" get= "Get_text" put= "Put_text" >
<property name= "Width" get= "Get_width" put= "Put_width" >
<method name= "SetFocus" internalname= "Htcfocus" >
<method name= "Additems" internalname= "Htcadditems" >
<event name= "Onyycenter" id= "Identer" >
<event name= "Onyycchoose" id= "Idchoose" >
<attach event= "Oncontentready" onevent= "Htcinit ()" >
</COMPONENT>
</PUBLIC>
<script language= "JavaScript" >
function Htcinit ()
{
Defaults.viewlink=document;
Defaults.viewinheritstyle=false;
Body_init ();
}
function Htcadditems (items)
{
var I,len;
Len=pcombo.options.length;
for (i=0;i<len;i++)
{pcombo.remove (0);}
for (i=0;i<items.length;i++)
{
var o;
if ((typeof items[i]) = = ' String ')
{
if (! Hasthevalue (Items,i))
{
O=document.createelement (' OPTION ');
O.text=items[i];
Pcombo.add (o);
}
}
}
}
function Htcfocus ()
{
Ptext.focus ();
}
function Get_text ()
{
return ptext.value;
}
function Put_text (Value)
{
Ptext.value=value;
}
function Get_width ()
{
return pCombo.style.width;
}
function Put_width (Value)
{
Pcombo.style.width=value;
}
</SCRIPT>

<script language= "JavaScript" >
function Body_init ()
{
var iright=pcombo.clientwidth;
var ibottom=pcombo.clientheight;
var ileft= (pcombo.clientwidth-18);
pcombo.style.clip= ' rect (0, ' +iright+ ', ' +ibottom+ ', ' +ileft+ ') ';
Ptext.style.width= (Pcombo.clientwidth);
Ptext.style.height= (Pcombo.clientheight);
Ptext.style.top=0;
ptext.style.left=0;
}
function Combo_select ()
{
Ptext.value=pcombo.options[pcombo.selectedindex].text;
}
function Text_chkkey ()
{
if (event.keycode==13)
{
Identer.fire ();
}
}
function Hasthevalue (sitems,i)
{
VAR II;
for (ii=0;ii<i;ii++)
{
if (Sitems[ii]==sitems[i])
return true;
}
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<select style= "position:absolute;left:0;top:0;" Name= "Pcombo" >
</SELECT>
<input style= "position:absolute;left:0;top:0;z-index:4000" onkeypress= "Text_chkkey ()" TYPE= "Text" NAME= "PText" >
</BODY>
</HTML>



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.