传统的ASP - JavaScript数组由VBScript的下拉列表填充 [英] classic asp - javascript array populated by vbscript drop down list

查看:141
本文介绍了传统的ASP - JavaScript数组由VBScript的下拉列表填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立一种基于下拉列表(不止一个)选择值填充JavaScript数组,每个除外下拉列表中的名称相同,因为它们是在创建for循环。现在我有:

I need to create a javascript array which is populated based on drop down lists' (more than one) selected values, except each drop down list has the same name because they are created in a for loop. Right now I have:

<script language="JavaScript">
     var array = [];
     var e = document.getElementById("phItemStatusID").value; //returns first ddl value
</script>

和后来的ASP code是我的下拉列表是从数据库中使用VBScript填充:

and later in the asp code is my drop down list which is populated from a database using VBScript:

<%for i = 0 to UBound(photoItemsArray,2)%> //for each item, generate DDL
<select name="phItemStatusID">
    itemStatusID = photoItemsArray(6,i) //get current selected value
    for j = 0 to UBound(photoStatusesArray,2)%> //for each possible status
    <option value="<%=photoStatusesArray(0,j)%>"
            <%if photoStatusesArray(0,j) = itemStatusID then%> 
                selected
            <%end if%>>
            <%=photoStatusesArray(1,j)%>
        </option>
    <%next%>
</select>
next%>

这工作在的情况下,只有生成的一个下拉列表。我快到的问题涉及情况下,人们不止一个下拉列表中的名称 phItemStatusID

This works in situations where there is only one dropdown list generated. The problem I'm running into involves instances where there is more than one drop down list with the name phItemStatusID.

变种E =的document.getElementById(phItemStatusID)值; 只返回第一个下拉列表的价值观和其他被忽略。我如何获得?

var e = document.getElementById("phItemStatusID").value; only returns the first drop down list's values and the others are ignored. How do I obtain them?

推荐答案

的document.getElementById(phItemStatusID)。值将得到第一个元素的值与ID phItemStatusID,因为在HTML中的ID都应该是独一无二的。

document.getElementById("phItemStatusID").value will get the value of first element with an ID of "phItemStatusID" because IDs in HTML are supposed to be unique.

如果你想获得第二个框的值,可以使用不同的ID。

If you want to get the value of a second box, use a different ID.

这篇关于传统的ASP - JavaScript数组由VBScript的下拉列表填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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