[原创]用JS给DropDownList添加新项!
<script language="javascript">
function addItem()
{
if (document.all("v").value=="") return;
var tOption = document.createElement("Option");
tOption.text=document.all("v").value;
tOption.value=document.all("DDL1").options.length+1;
document.all("DDL1").add(oOption);
}
</script>
function addItem()
{
if (document.all("v").value=="") return;
var tOption = document.createElement("Option");
tOption.text=document.all("v").value;
tOption.value=document.all("DDL1").options.length+1;
document.all("DDL1").add(oOption);
}
</script>
<DIV style="BORDER-RIGHT: 1px dotted; BORDER-TOP: 1px dotted; Z-INDEX: 103; LEFT: 304px; BORDER-LEFT: 1px dotted; WIDTH: 304px; BORDER-BOTTOM: 1px dotted; POSITION: absolute; TOP: 288px; HEIGHT: 160px; BACKGROUND-COLOR: ghostwhite"
ms_positioning="GridLayout"><INPUT onclick="addItem();" style="Z-INDEX: 101; LEFT: 136px; WIDTH: 99px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
type="button" value="添加新项目" id="addnew">
<asp:DropDownList id="DDL1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 96px" runat="server"
Width="96px">
<asp:ListItem Value="0">北京</asp:ListItem>
<asp:ListItem Value="1">天津</asp:ListItem>
<asp:ListItem Value="2">上海</asp:ListItem>
</asp:DropDownList><INPUT id="v" style="Z-INDEX: 103; LEFT: 32px; WIDTH: 96px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
type="text" size="10"></DIV>
ms_positioning="GridLayout"><INPUT onclick="addItem();" style="Z-INDEX: 101; LEFT: 136px; WIDTH: 99px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
type="button" value="添加新项目" id="addnew">
<asp:DropDownList id="DDL1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 96px" runat="server"
Width="96px">
<asp:ListItem Value="0">北京</asp:ListItem>
<asp:ListItem Value="1">天津</asp:ListItem>
<asp:ListItem Value="2">上海</asp:ListItem>
</asp:DropDownList><INPUT id="v" style="Z-INDEX: 103; LEFT: 32px; WIDTH: 96px; POSITION: absolute; TOP: 56px; HEIGHT: 22px"
type="text" size="10"></DIV>