上代码第一段 动态设置select空间里的选项
      <select multiple id="listDomainSelect" name="listDomainSelect" style="width:300px;height:200px;">
                 <%           
                  if(listDomain!=null)
                       {
                         for(String domain:listDomain)
                             {                             
                             String str = domainRegularMap.get(domain);
                              System.out.println("放入select以前,str="+str);
                             %>                              
                             <option value=<%=str%>><%=domainRegularMap.get(domain)%></option>
                          <%   
                          System.out.println("放入select以后,str="+str);
                       }
                    } %>
                   
</select>对应的控制台输出语句为:
放入select以前,str=www  链接文本:weqw  更新时间:eqwe  链接图片:ewqe  节目图片:  节目描述:  频道  标签  备用数值字段1  备用数值字段2  备用数值字段3  备用文本字段1  备用文本字段2  备用文本字段3放入select以后,str=www  链接文本:weqw  更新时间:eqwe  链接图片:ewqe  节目图片:  节目描述:  频道  标签  备用数值字段1  备用数值字段2  备用数值字段3  备用文本字段1  备用文本字段2  备用文本字段3
这么看的话,option的value值已经被设置成str了第二段代码 使用js访问option的value值
          if(obListDomainSelect[i].selected==true)
        {
          alert("被选中的选项value为:"+obListDomainSelect[i].value);                      
                 }        这个时候,提示框只弹出   被选中的选项value为:www  也就是说只取得了value里面的前三个字符  ,会是什么原因造成的呢?求解!!

解决方案 »

  1.   

     <select multiple id="listDomainSelect" name="listDomainSelect" style="width:300px;height:200px;">    document.getElementById("listDomainSelect").options(document.getElementById("listDomainSelect").selectedIndex).value;document.getElementById("listDomainSelect").options(document.getElementById("listDomainSelect").selectedIndex).text;
      

  2.   

    document.getElementById("listDomainSelect").options(document.getElementById("listDomainSelect").selectedIndex).innerText;