在 flex 4 中设置下拉列表的默认索引

发布于 2024-10-05 03:37:32 字数 156 浏览 0 评论 0原文

我有一个下拉列表,它从 php Web 服务方法获取其数据。这个响应类似于:

数组('id'=>整数,'name'=>'lin')

当页面加载时,我想最初将选定的索引设置为“lin”。我该怎么做?

I have a drop down list that gets its data from a php web service method.This response is smthing like :

array('id'=>integer,'name'=>'lin')

When the page loads, I want to set the selected index to "lin" initially. How do I do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2024-10-12 03:37:32

您只需要设置下拉列表控件的 selectedIndex 属性即可。

前任。

dwl.selectedIndex = 1; // "Index of "lin"

你应该这样做。

var iIndex:int;

for(var i:int = 0; i < arrResponse.length; i++)
{

       // if(Array(arrResponse[i])[1] == "lin")

       if(Array(arrResponse[i]).name == "lin") {
            iIndex = i;

       }

}

dwl.selectedIndex = iIndex;

you just need to set selectedIndex property of dropdownlist control.

ex.

dwl.selectedIndex = 1; // "Index of "lin"

you should do this.

var iIndex:int;

for(var i:int = 0; i < arrResponse.length; i++)
{

       // if(Array(arrResponse[i])[1] == "lin")

       if(Array(arrResponse[i]).name == "lin") {
            iIndex = i;

       }

}

dwl.selectedIndex = iIndex;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文