如何使用Javascript加载选定索引中的值 [英] How Do I Load The Values In Selected Index Changing Using Javascript

查看:54
本文介绍了如何使用Javascript加载选定索引中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的usercontrol我正在使用dorpdown列表控件,这里我想根据所选索引使用javascript更改获取值



帮我解决这个问题

提前谢谢



Velsamy

hi all,

im my usercontrol i am using dorpdown list controls , here i want to get the values based on selected index changed using javascript

help me to solve this
thanks in advance

Velsamy

推荐答案

由于您希望使用JavaScript进行操作,因此您必须坚持使用HTML标记并忘记ASP.NET控件。一旦你创建了初始选择元素,就必须使用HTML标记等对它进行任何更改。



首先你需要成为处理变更事件。看一下jQuery .change()API [ ^ ]。



考虑使用以下HTML,



Since you want to be doing it using JavaScript, you will have to stick to the HTML markup and forget the ASP.NET Controls. Once you've create the initial select element, any changes to be made to it would have to be made using HTML markup and so on.

First you need to be handling the change event. Have a look at the jQuery .change() API[^].

Consider the following HTML to work for,

<select id="select">
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>





现在这可以作为您需要成为我们的主要选择元素加载数据的值。





Now this can serve as the main select element from which you need to be using the value to load the data.


' #select')。change( function (){
// 值已更改,获取索引
var index =
('#select').change(function () { // value has changed, get the index var index =


this )。val();
});
(this).val(); });





现在您可以使用此索引号填充HTML内容中的下一个select元素,无论是使用ajax从服务器加载内容,还是在服务器中创建选项节点HTML标记本身。



Now you can use this index number to populate the next select element in your HTML content, whether using ajax to load the content from server, or to create option nodes in the HTML markup itself.


这篇关于如何使用Javascript加载选定索引中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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