LJL-Solution DropDownList既可以拉又可以编辑 的一个解决方案
方案原理: 下拉的时候 前台利用js将DropDownList的值替换给 input,style样式 将两个控件重叠;
后台保存 input 控件的值,页面加载的时候也加载input的值 ;编辑的是input;这就实现了既可以下拉,又可以编辑了。
cs:
.noprint
{
display: none;
}
js:
function changeValues(ctrl1,ctrl2)
{
document.getElementById(ctrl2).value = document.getElementById(ctrl1).value;
}
Html:
Test001
<asp:DropDownList ID="ddlTest" runat="server" style=" width:140; position:absolute;clip: rect(2 100% 90% 121)" onchange="changeValues('ddlTest','txtTest')" class="NoPrint">
<asp:ListItem Value="" />
<asp:ListItem Value="1级" />
<asp:ListItem Value="2级" />
<asp:ListItem Value="3级" />
<asp:ListItem Value="4级" />
</asp:DropDownList>
<input id="txtTest" type="text" size="22" runat="server" style="font-size:12px; border: none; border-bottom: 1px solid #a0a0a0; background-color:transparent;"/>
cs: ........就不写了,到这里,你应该明白了。

浙公网安备 33010602011771号