The value of the TextBox changes with the DropDownList value

Source: Internet
Author: User

Transferred from: http://bytes.com/topic/asp-net/answers/443065-textbox-value-change-select-other-item-dropdownlist

You need to add the below JavaScript on ur HTML section of the page

<script language= "JavaScript" >
function Showvalue ()
{
Document. form1["Textboxname"].value =
Document. form1["Dropdownvalue"].value
}
</script>
The codebehind file Add this line

DROPDOWNCONTROL.ATTRIBUTES.ADD ("onchange", "Javascr Ipt:showvalue ()");

Now if you change the value of the drop, the Textbox would be
Filled without refreshing the page

Http://forums.asp.net/t/1796597.aspx?How+to+select+a+value+in+dropdownlist

"Server"><script type="Text/javascript">function Sethref () {varTEXTB = document.getElementById ('<%=TextBox1.ClientID%>'); varParlab = document.getElementById ('<%=Dropdown1.ClientID%>'). Options[document.getelementbyid ('<%=Dropdown1.ClientID%>'). Selectedindex].text; if(parlab!='--select deptname--') {Textb.value=Parlab}Else{Textb.value="'; }       }       </script> <title></title>"Form1"runat="Server"> <div> <asp:button id="Reload"runat="Server"onclick="Reload_click"/> <asp:textbox id="TextBox1"runat="Server"></asp:TextBox> <asp:dropdownlist id="Dropdown1"runat="Server"Onchange="sethref ();"> <asp:listitem>--SelectDeptname--</asp:listitem> <asp:ListItem>mama</asp:ListItem> <asp:listitem>kaka</asp: listitem> <asp:ListItem>nana</asp:ListItem> </asp:DropDownList> </div> </fo Rm></body>

http://blog.csdn.net/lvincent_china/article/details/7209517

"http://www.w3.org/1999/xhtml">"Server"> <title></title> <script type="Text/javascript"Src=".. /js/jquery-1.4.2.min.js"></script> <script type="Text/javascript">$ (document). Ready (function () {$ ('#<%=dropdownlist1.clientid%>'). Bind ("KeyUp Change", function () {//Use bind () to attach a handler to the KeyUp and change events:$('#message'). Text (""); if($( This). val ()! ="") {//Check If the selected value of the DropDownList is empty$('#message'). Text ("Text:"+ $( This). Find (": Selected"). Text () +"Value:"+ $( This). Val ());//Retrieve the Text/value pair and display in the div area ' message ':                }                Else {                    $('#message'). Text (""); }            })        })    </script>"Form1"runat="Server"> <div> <asp:dropdownlist id="DropDownList1"runat="Server"> <asp:listitem value=""text="Please select"></asp:ListItem> <asp:listitem value="1"text=" Standard"></asp:ListItem> <asp:listitem value="2"text="Silver"></asp:ListItem> <asp:listitem value="3"text="Gold"></asp:ListItem> <asp:listitem value="4"text="Premier"></asp:ListItem> </asp:DropDownList> </div> <div id="message"></div> </form></body>

The value of the TextBox changes with the DropDownList value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.