TextBox的值随dropdownlist值而变化
转自:http://bytes.com/topic/asp-net/answers/443065-textbox-value-change-select-other-item-dropdownlist
You need to add the below javascript in ur html section of the page
<script language="javascript">
function ShowValue()
{
document.Form1["textboxname"].value =
document.Form1["dropdownvalue"].value
}
</script>
and in the codebehind file add this line
Dropdowncontrol.Attributes.Add("onchange","javascr ipt:ShowValue()");
Now when you change the value in the drop down, the Textbox will be
filled without refreshing the page
http://forums.asp.net/t/1796597.aspx?How+to+select+a+value+in+dropdownlist
<head runat="server">
<script type="text/javascript">
function sethref() { var Textb = document.getElementById('<%=TextBox1.ClientID%>');
var parLab = document.getElementById('<%=Dropdown1.ClientID%>').options[document.getElementById('<%=Dropdown1.ClientID%>').selectedIndex].text; if(parLab!='--select deptname--'){
Textb.value = parLab
} else{ Textb.value =''; } }
</script>
<title></title>
</head>
<body>
<form id="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>--select deptname--</asp:ListItem>
<asp:ListItem>mama</asp:ListItem>
<asp:ListItem>kaka</asp:ListItem>
<asp:ListItem>nana</asp:ListItem> </asp:DropDownList>
</div>
</form>
</body>
</html>
http://blog.csdn.net/lvincent_china/article/details/7209517
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="" Text="please select"></asp:ListItem>
<asp:ListItem Value="" Text="Standard"></asp:ListItem>
<asp:ListItem Value="" Text="Silver"></asp:ListItem>
<asp:ListItem Value="" Text="Gold"></asp:ListItem>
<asp:ListItem Value="" Text="Premier"></asp:ListItem>
</asp:DropDownList>
</div>
<div id="message"></div>
</form>
</body>
</html>
TextBox的值随dropdownlist值而变化的更多相关文章
- MVC控制器获取@Html.DropDownList值
MVC控制器获取@Html.DropDownList值 发表于 2014 年 4 月 1 日 作者 efour — 暂无评论 先贴一段代码,演示@Html.DropDownList的使用. 前台 前台 ...
- jQuery封装自定义事件--valuechange(动态的监听input,textarea)之前值,之后值的变化
jQuery封装自定义事件--valuechange(动态的监听input,textarea)之前值,之后值的变化 js监听输入框值的即时变化 网上有很多关于 onpropertychange.oni ...
- Facebook开源时间序列内存数据库Beringei,追求极致压缩率——如果是int根据大多数时间序列中的值与相邻数据点相比并没有显著的变化,只要使用XOR将当前值与先前值进行比较,然后存储发生变化的比特。最终,该算法将整个数据集至少压缩了90%
转自:http://www.infoq.com/cn/news/2017/02/Facebook-Beringei 2017年2月3日,Facebook宣布将开源他们的高性能时序数据存储引擎Berin ...
- EF里查看/修改实体的当前值、原始值和数据库值以及重写SaveChanges方法记录实体状态
本文目录 查看实体当前.原始和数据库值:DbEntityEntry 查看实体的某个属性值:GetValue<TValue>方法 拷贝DbPropertyValues到实体:ToObject ...
- Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence
Oracle新表使用序列(sequence)作为插入值,初始值不是第一个,oraclesequence 使用oracle11g插入数据时遇到这样一个问题: 1 --创建测试表-- 2 CREATE T ...
- javascript中值传递与值引用的研究
今天重新看了一下<javascript高级程序设计>,其中讲到了javascript中的值传递和值引用,所以就自己研读了一下,但是刚开始没有明白函数中的参数只有值传递,有的场景好像参数是以 ...
- easyUI validatebox设置值和获取值,以及属性和方法
一:表单元素使用easyui时,textbox和validatebox设置值和获取值的方式不一样[转] 1.为text-box设置值只能使用id选择器选择表单元素,只能使用textbox(" ...
- JavaScript数据操作--原始值和引用值的操作本质
我的一句话总结:原始值不管是变量赋值还是函数传递都不会改变原值,引用值不管是变量赋值还是函数传递,如果新变量重新赋值,则不会影响原引用值,如新变量是直接操作,就会影响原引用值. 首先明确,值和类型是两 ...
- easyui-textbox 和 easyui-validatebox 设置值和获取值
表单作如下定义:该input使用easyui的"easyui-textbox" <input id="addSnumber" style="wi ...
随机推荐
- php生成纯数字、字母数字、图片、纯汉字的随机数验证码
现在讲开始通过PHP生成各种验证码旅途,新手要开车了,请刷卡! 首先,我们开始先生成一个放验证码的背景图片 注:没有Imagejpg()这个函数,只有imagepng()函数 imagecreatet ...
- PHP:implode(),emplode() 字符串数组,数组字符串转换函数
1.implode()-Join array elements with a string(把数组元素组合为一个字符串.) string implode([string $separator,] ar ...
- STM32启动流程
启动文件主要工作: . 设置堆栈指针SP=_initial_sp . 设置PC指针=Reset_Handler . 配置系统时钟 . 配置外部SRAM用于程序变量等数据存储(可选) . 调用C库中的_ ...
- python序列化(数据本地存放持久性存储)和反序列化
http://blog.csdn.net/uestcyao/article/details/7874817 #读取图片并存储为矩阵 from scipy.misc import imread im = ...
- Jmeter模拟http请求
一.获取用户信息(GET请求):http://hostname/getuser?userid=1 1.打开jmeter,创建一个线程组,再添加一个http请求Sampler 2.设置域名.路径.请求方 ...
- 在DOS界面下快速进入目录的技巧
在DOS界面如果想进入某一目录还是比较困难的,尤其是有长目录名和中文目录名的时候. 比如:要进入“D:/工具箱/杀毒软件”这个目录. 1.在Windows下进入这个目录. 2.在地址栏输入 C:/WI ...
- java面向对象思想1
1.面向对象是面向过程而言.两者都是一种思想.面向过程:强调的是功能行为.(强调过程.动作)面向对象:将功能封装进对象,强调了具备了功能的对象.(强调对象.事物)面向对象是基于面向过程的.将复杂的事情 ...
- 【NTT】bzoj3992: [SDOI2015]序列统计
板子题都差点不会了 Description 小C有一个集合S,里面的元素都是小于M的非负整数.他用程序编写了一个数列生成器,可以生成一个长度为N的数 列,数列中的每个数都属于集合S.小C用这个生成器生 ...
- ElasticSearch High Level REST API【6】获取集群信息
ElasticSearch 可以通过info()方法检索群集信息: public void info(){ RestHighLevelClient client = elasticClient.get ...
- String&StringBuffer&StringBuilder区别
String String类是final类故不可以继承,也就意味着String引用的字符串内容是不能被修改.String有两种实例化方式: (1)直接赋值(例中,String str = &q ...