如何根据下拉菜单中选择的项目在标签中显示值. [英] How to display a value in the label based on the item selected in the drop down.

查看:73
本文介绍了如何根据下拉菜单中选择的项目在标签中显示值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有

我有一个下拉控件(字段名称)和标签(对象名称).我想根据下拉列表中选择的字段名称显示对象名称.
如何使用XML HTTP在标签中显示值.任何人都可以帮助我..在此先感谢.

all

I have a drop down control (Fields Names) and a label (Object Name). I want to display the object name based on the field name selected in the drop down.
How to display the value in the label using XML HTTP. Can any one help me.. thanks in advance.

推荐答案

在下拉列表selectedindexchanged事件中放置以下代码.



In dropdown selectedindexchanged event place the following code.



//---XMLHttpRequest
           var xmlhttp;
           if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
               xmlhttp = new XMLHttpRequest();
           }
           else {// code for IE6, IE5
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
           }
           xmlhttp.onreadystatechange = function () {
               if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                   var ReturnVal= xmlhttp.responseText;
                   ReturnVal = ReturnVal.replace('',"");
                   ReturnVal=ReturnVal.split("~")[0];
                   document.getElementById("label").value=ReturnVal;

               }
           }
           xmlhttp.open("GET", "http://localhost:1101/aspx/GetObjectName.aspx?FieldsNames=" + FieldsNames+ "&FieldsNamesValue=" + FieldsNamesValue, true);
           xmlhttp.send();



在GetObjectName.aspx页中,根据需要获取相应的值.
即将您的数据集保留在会话中并通过使用select方法获取值;
DataRow [] dr = dataset.Tables [0] .select("condition =" + FieldsNamesValue)

谢谢,
sanjeev



In the GetObjectName.aspx page get the values accordingly as your requirement.
i.e keep your dataset in session and get the values by using select method;
DataRow[] dr=dataset.Tables[0].select("condition="+FieldsNamesValue)

Thanks,
sanjeev


这篇关于如何根据下拉菜单中选择的项目在标签中显示值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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