코드는 usercontrol에서 가져온 것입니다.
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>Maer</asp:ListItem>
<asp:ListItem>Cor</asp:ListItem>
에
<asp:Button ID="btn1" runat="server" Style="font-size: small; width: 70px; font-weight: lighter" Text="Add" OnClick="btn1_click" />
<asp:ListBox ID="ListBox2" runat="server" SelectionMode="Multiple" Width="220px"> </asp:ListBox>
자바 스크립트 기능
function btn1_click()
{
드롭 다운에서 값을 가져 와서 목록 상자에 추가하려면 어떻게해야합니까?
$("#btn1").click(function (event) {
var $ddl = $("#MC_ucOperations_DropDownList2"); Getting the id of the dropdown
var $list = $("#MC_ucOperations_ListBox2"); // Getting the id of the listbox
var selValue = $ddl.val();
var selText = $ddl.find("option:selected").text();
var $opt = $("<option></option>");
$opt.html(selText);
$opt.attr("value", selValue);
$list.append($opt);
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다