当我们更改下拉列表中的值时,如何在文本框中更改值 [英] how to value change in text box when we change the value in drop down list

查看:80
本文介绍了当我们更改下拉列表中的值时,如何在文本框中更改值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们更改下拉列表中的值时,如何更改文本框中的值

解决方案

编写代码以更改文本框文本,在下拉列表中选择索引已更改的活动。



 受保护  void  Dropdownlist1_SelectedIndexChanged( object  sender,EventArgs e)
{
TextBox1.Text = ; // 此处更改值

}


您可以 从 =code-sdkkeyword>  aspx页面使用 javascript。 

遵循以下代码

< asp:dropdownlist id = ddlreport runat = server onclick = fnconchange() xmlns:asp = #unknown >
< asp:textbox id = txtname runat = server > < / asp:textbox >


< script type = TEX t / javascript >
function fnconchange()
{
var ddlReport = document.getElementById( <%= ddlreport.ClientID%>);
var Text = ddlReport.options [ddlReport.selectedIndex] .text;
var Value = ddlReport.options [ddlReport.selectedIndex]。 value ;
if (Value == ram // (您选择的值
{
文件。 getElementById( <%= textBox.ClientID%>)。 value = ram;
}

}
< / script > < / asp:dropdownlist >


how to value change in text box when we change the value in drop down list

解决方案

Write the code to change textbox text ,inside the dropdown list selected index changed event.

protected void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
   {
         TextBox1.Text=""; // Change value here

   }


you can do the same from aspx page also using javascript.

follow the  below code

<asp:dropdownlist id="ddlreport" runat="server" onclick="fnconchange()" xmlns:asp="#unknown">
<asp:textbox id="txtname" runat="server"></asp:textbox>


<script type="text/javascript">
function fnconchange()
{
var ddlReport = document.getElementById("<%=ddlreport.ClientID%>");
       var Text = ddlReport.options[ddlReport.selectedIndex].text;
       var Value = ddlReport.options[ddlReport.selectedIndex].value;
if(Value =="ram")//(your selected value
{
document.getElementById("<%=textBox.ClientID%>").value = "ram";
}

}
</script></asp:dropdownlist>


这篇关于当我们更改下拉列表中的值时,如何在文本框中更改值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆