在javascript中列出ctrl [英] list ctrl in javascript

查看:55
本文介绍了在javascript中列出ctrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何使用Java脚本从列表中获取多个值?我可以选择多个值,但只有一个值.请帮助我. (这是我的代码)

Hi everyone,

How to get multiple values from a list using java script? I can select multiple values but i got only a single value. pls help me. (this is the code i have )

var arr=document.f1.s1.options[document.f1.s1.selectedIndex].value;


(这里f1是表单名称,s1是列表名称)

关于
shajna v.Akbar


(here f1 is the form name and s1 is the list name)

with regards
shajna v.Akbar

推荐答案

如何使用Java脚本从列表中获取多个值
您上面的代码用于特定索引.创建一个for循环并遍历索引.获取您寻求的所有价值.
例如:
How to get multiple values from a list using java script
The code that you have above is for a specific index. Create a for loop and loop over the index. Get all the values you seek.
Ex:
var arr = "SelectedValues = ";
for(int i=0; i < document.f1.s1.options.length; ++i)
{
  arr= arr + "," + document.f1.s1.options[i].value;
  // Use arr
}


这篇关于在javascript中列出ctrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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