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 ...
随机推荐
- svn项目权限控制
[groups] g_manager = zhangsan g_php = lisi g_test = wangwu [/] @g_manager = rw [project:/] @g_manage ...
- cms-友情链接实现静态化
service: package com.open1111.service.impl; import java.util.List; import javax.servlet.ServletConte ...
- iOS 常用正则表达式
今天看到一个正则表达式的文章,总结的挺好的,就自己转载一下,我还会陆续加入一些我自己看到常用的正则表达式 (原地址:http://www.code4app.com/blog-721976-112.ht ...
- python_40_通过脚本转换参数实现替换
import sys f=open('yesterday','r',encoding='utf-8') f_new=open('yesterday_update','w',encoding='utf- ...
- install cmake,install torch7
cmake http://blog.csdn.net/jesse__zhong/article/details/21290675 torch7 http://wanghaitao8118.blog.1 ...
- Sql优化器究竟帮你做了哪些工作?
关系型数据库的一大优势之一,用户无需关心数据的访问方式,因为这些优化器都帮我们处理好了,但sql查询优化的时候,我不得不要对此进行关注,因为这牵扯到查询性能问题. 有经验的程序员都会对一些sql优化了 ...
- JavaScript 交换两个变量的值
方法一 let a = "a", b = "b"; console.log(a, b); let t = a; a = b; b = t; console.lo ...
- ajax 的 promise
$.when().done().fail() $.when($.ajax("test1.html"),$.ajax("test2.html")).done(fu ...
- shell中字符串基本用法
前言 今天在写脚本时,发现前阶段使用过的一些用法还是需要去百度查找,并且找到的答案还需要自己去筛选,耽误写脚本时间,这一篇对字符串之间的比较和逻辑判断都非常详细,借鉴他人之作,资源共享. 本片主要说明 ...
- 牛客NOIP普及组R1 C括号(dp)
题意 题目链接 Sol maya普及组的dp都要想很长时间,我真是越来越菜了qwq 设$f[i][j]$表示当前到第$i$个位置,剩下$j$个左括号没被匹配 转移的时候判断一下即可 /* */ #in ...