下拉列表跟文本框同步

//下拉选择,文本输入框同步

function ShowReasonInTextBox(ddl, txtId) {

var nowText
= ddl.options[ddl.selectedIndex].text;

if (nowText != "") {

document.getElementById(txtId).value
= nowText;

}s

else {

document.getElementById(txtId).value
= "";

}

}



//下拉列表

<asp:DropDownList ID="ddlReason0" runat="server" style="width:600px;" AutoPostBack="false" onchange="ShowReasonInTextBox(this,'Reason');">

</asp:DropDownList>

<asp:DropDownList ID="ddlReason1" runat="server"

style
="width:600px;" AutoPostBack="false" onchange="ShowReasonInTextBox(this,'Reason');">

</asp:DropDownList>

<asp:DropDownList ID="ddlReason2" runat="server"

style
="width:600px;" AutoPostBack="false" onchange="ShowReasonInTextBox(this,'Reason');">

</asp:DropDownList>

//多行文本框

<textarea id="Reason" runat="server" style="width: 600px;" class="input" rows="8"></textarea>
posted @ 2011-03-29 14:25  syy-燕子  阅读(201)  评论(0编辑  收藏  举报