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 ...
随机推荐
- 如果CDN服务器出了问题,怎么做不影响自己的网站
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3.jquery.min.js"></ ...
- PHP:implode(),emplode() 字符串数组,数组字符串转换函数
1.implode()-Join array elements with a string(把数组元素组合为一个字符串.) string implode([string $separator,] ar ...
- Android(java)学习笔记104:Framework运行环境之启动SystemServer进程
1. SystemServer进程 SystemServer进程是zygote孵化出的第一个进程,该进程是从ZygoteInit.java的main函数中调用startSystemServe ...
- python剑指offer 实现树的子结构
题目描述 输入两棵二叉树A,B,判断B是不是A的子结构.(ps:我们约定空树不是任意一个树的子结构) # -*- coding:utf-8 -*- # class TreeNode: # def __ ...
- python_35_进度条
import sys for i in range(50): sys.stdout.write("+")#此命令不会像print语句执行一次,换行一次\ sys.stdout.fl ...
- SSH框架快速搭建(Maven)
1.新建Maven项目ssh 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=& ...
- 外网访问FTP服务,解决只能以POST模式访问Filezilla的问题
在内网可以正常使用PASV,但是在外网不行,导致数据传输慢或者根本连接不了,在FlashFXP中通过日志,找到了解决方法解决方法1.在Filezilla——Edit——Settings——Passiv ...
- pymysql 简单操作数据库
#!/usr/bin/env python #-*- coding:utf-8 -*- # author:leo # datetime:2019/4/24 15:22 # software: PyCh ...
- Cesium专栏-测量工具测距、测面、测高(附源码下载)
Cesium Cesium 是一款面向三维地球和地图的,世界级的JavaScript开源产品.它提供了基于JavaScript语言的开发包,方便用户快速搭建一款零插件的虚拟地球Web应用,并在性能,精 ...
- nginx下配置Yii2 rewrite、pathinfo等
环境说明: 我试用的lnmp安装包安装的nginx,nginx版本是1.14.1 server { listen ; server_name www.baidu.com; #access_log /d ...