将项目附加到组合框中 [英] appending the items into the combo box

查看:117
本文介绍了将项目附加到组合框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在特定次数的组合框中添加项目。这是我的代码。

I need to add the item in a combo box for a particular number of times.This is my code.

         for(i=0;i<3;i++)
    {
         othercompaniesli.innerHTML=  '<select onchange="document.location.href = this.options[this.selectedIndex].value;"><option VALUE="http://www.google.com">'+fStr1[0]+'</option>  </select>';
     }

这里我想添加fStr1字符串3次。时间。这是for循环是工作,但只有项目值不附加。只有最后一个值被添加在组合框中。任何人都可以帮助我如何将项目附加到组合框中。

Here I want to add the fStr1 string 3 times.But it adds only one time.That is the for loop is working but only item value is not appending.Only last value is added in the combo box. Can anyone help me how to append the items into combo box.

推荐答案

var tmpStr = '<select onchange="document.location.href = this.options[this.selectedIndex].value;">';

for(i=0;i<3;i++)
{
    tmpStr+=  '<option VALUE="http://www.google.com">'+fStr1[0]+'</option>  ';
}

tmpStr = '</select>';

othercompaniesli.innerHTML = tmpStr;

这篇关于将项目附加到组合框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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