简体   繁体   English

如何使用“旧”(HTML5之前的)HTML控制html select元素中的可见项?

[英]How can I control the visible items in an html select element using “old” (pre-HTML5) HTML?

I have an html select element that, based on a value set elsewhere, is supposed to show one of two pairs of value. 我有一个html select元素,该元素基于其他地方设置的值,应该显示两对值之一。 In one case, it should be "New" and "Assumed", and in the other "Existing" and "Organic Growth" 在一种情况下,应为“新的”和“假定的”,在另一种情况下,应为“现有的”和“有机增长”

So currently I'm creating it with all of them, like so: 因此,目前我正在与所有这些对象一起创建它,如下所示:

<tr>
    <td nowrap align="left" valign="top">
      <font color="<%=Session("TextColor")%>" style="font: 8pt arial">Subcategory:&nbsp;</font>  
        </td>
    <td nowrap align="left" valign="top">
    <select name="subcategory" color="<%=Session("TextColor")%>" style="font: 8pt arial" onchange="UpdateFlag=true;">
      <option value="3">Organic Growth
      <option value="2">Existing
      <option value="1">Assumed
      <option value="0">New
    </select>
    </td>
</tr>   

But I want to only show two of these values at a time, based on the value of IsNewBusiness: 但是我只想一次基于IsNewBusiness的值显示其中两个值:

Dim IsNewBusiness As Boolean

...after this: ...在这之后:

currentYear = Year(Now)
SQLString = "Select NewBiz from MasterUnitsprojSales where CYear = " & currentYear & " and Unit = '" & Unit & "'"
adoRS.Open(SQLString, adoCon)
IsNewBusiness = TRUE 'default (if record not found)
If Not adoRS.EOF Then
    IsNewBusiness = adoRS.Fields.Item(0).Value <> 0
End If
adoRS.Close()

Knowing the value of IsNewBusiness, how can I specify which pair of items in the html select are visible? 知道IsNewBusiness的价值,我如何指定html select中的哪对项目可见? Can I add some "inline" javascript or something? 我可以添加一些“内联” javascript吗?

I'd leave javascript out of it: 我将不使用javascript:

<tr>
    <td nowrap align="left" valign="top">
      <font color="<%=Session("TextColor")%>" style="font: 8pt arial">Subcategory:&nbsp;</font>  
        </td>
    <td nowrap align="left" valign="top">
    <select name="subcategory" color="<%=Session("TextColor")%>" style="font: 8pt arial" onchange="UpdateFlag=true;">
<% if not isNewbusienss then %>
      <option value="3">Organic Growth
      <option value="2">Existing
<% else %>
      <option value="1">Assumed
      <option value="0">New
<% end if %>
    </select>
    </td>
</tr>

Note: My vbscript is very rusty so you may need to iron out some bugs 注意:我的vbscript非常生锈,因此您可能需要消除一些错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM