JS:
document.οnkeydοwn=setCode;
function setCode(){
if (event.keyCode==40)
{
var srcElem = document.activeElement
var testval = srcElem.name;
if(testval=="TextAdmissionDiagnosis")
{
document.getElementById("lsBoxInfo").focus();
}
}
if(event.keyCode==13)
{
event.returnValue = false;
var srcElem = document.activeElement
var testval = srcElem.name;
if(testval=="lsBoxInfo")
{
getData();
}
}
}
function getSelect(a) {
if(a.value=="")
return;
var CheckIdList=MedicalTwo_AddMedicalTwo.GetLC_RememberCode(a.value).value;
if(CheckIdList.length != 0)
{
document.getElementById("lsBoxInfo").style.display="block";
var slt = document.getElementById("lsBoxInfo");
for (i = slt.options.length - 1; i >= 0; i--) {
slt.options.remove(i);
}
for (i = 0; i < CheckIdList.length; i++) {
option = new Option();
option.text = CheckIdList[i].split('@')[0];
option.value = CheckIdList[i].split('@')[1];
slt.options.add(option);
}
}else
{
document.getElementById("lsBoxInfo").style.display="none";
}
}
function getData()
{
var province=document.getElementById("lsBoxInfo");
var pindex = province.selectedIndex;
var pValue = province.options[pindex].value;
var pText = province.options[pindex].text;
document.getElementById("TextAdmissionDiagnosis").innerText=pText;
document.getElementById("lsBoxInfo").style.display="none";
}
function Setoubl()
{
var srcElem = document.activeElement
var testval = srcElem.name;
if(testval != "TextAdmissionDiagnosis" && testval!="lsBoxInfo")
{
document.getElementById("lsBoxInfo").style.display="none";
}
}
Html:
<td class="right_chaxun_bai" align="left" colspan="3" style="height: 24px; position:relative;">
<div id="divPropertyInfo" style="position:absolute; z-index:20; ; width:100%; left: 0px; top: 0px;">
<input id="TextAdmissionDiagnosis" type="text" runat="server" style="width: 90%" class="right_chaxun_input" AutoComplete="off" />
</div>
<select id="lsBoxInfo" runat="server" style="display: none;position:absolute; z-index:20; top:20px; width:90%;" multiple="true" ></select>
</td>
事件:
this.TextAdmissionDiagnosis.Attributes.Add("onblur", "Setoubl();");
this.TextAdmissionDiagnosis.Attributes.Add("onkeyup", "getSelect(this);");
this.lsBoxInfo.Attributes.Add("onblur", "Setoubl();");
//双击
this.lsBoxInfo.Attributes.Add("ondblclick", "getData();")