在 ASP 经典页面上隐藏一个单选按钮选项

Hide one radio button option on ASP Classic page

几个月前我问过如何隐藏从数据库中提取的经典 ASP 页面上的一些下拉选项,以便用户无法 select 这些选项。但是现在在剩下的选项之一上出现了 3 个单选框选项。我必须删除其中一个选项。根据 Chrome.

,我需要删除的选项称为 value="_BML7(B)"

上次我将以下代码插入到 include.asp 文件中,效果很好,但那是为了隐藏下拉选项。我需要从当前下拉选项中隐藏一个单选按钮选项。

Sub buildDropDownList(strCurrentSelection, objListData, strCodeName, strDescriptionName, blnIncludeOther)
    If Not objListData.BOF Then
        objListData.MoveFirst
    End If
    Dim currentCodeValue
While Not objListData.EOF
    currentCodeValue = objListData(strCodeName)
    If (UCase(currentCodeValue)<>"_04GIDBM") And _
        (UCase(currentCodeValue)<>"_05GIDFM") And _ 
        (UCase(currentCodeValue)<>"_03MIS(Q") And _ 
        (UCase(currentCodeValue)<>"_06GIDMS") And _ 
        (UCase(currentCodeValue)<>"_08EXHRM") And _ 
        (UCase(currentCodeValue)<>"_10EXMKT") And _ 
        (UCase(currentCodeValue)<>"_12EXTTH") And _ 
        (UCase(currentCodeValue)<>"_15AFT") And _ 
        (UCase(currentCodeValue)<>"_16HSC") And _
        (UCase(currentCodeValue)<>"_18LTD") And _
        (UCase(currentCodeValue)<>"_19EBM") And _    
        (UCase(currentCodeValue)<>"_17EXHSC") Then
        Response.Write "<option value='" & currentCodeValue & "' "
        If StrComp(strCurrentSelection, currentCodeValue, 1) = 0 then
            Response.Write "selected"
        End If
        Response.Write ">" & objListData(strDescriptionName) & "</option>" & VbCrLf
    End If

我真的需要帮助,在此先感谢大家的帮助!我不太擅长 Classic ASP 但我正在尝试。

这是我上次在 include.asp 文件中插入的代码。

<p align="center">
            <%
                do until rsProgramLevel.EOF
                    Response.Write "<input type=""radio"" name=""programcode"" onclick=""onProgramCode()"" "
                    Response.Write "value=""" & rsProgramLevel("ProgramCode") & """ "
                    if rsProgramLevel("ProgramCode") = strProgramCode then
                        Response.Write "checked"
                    end if
                    Response.Write ">"
                    Response.Write "&nbsp;"
                    Response.Write rsProgramLevel("LevelDescription") & " (&pound;" & FormatNumber(rsProgramLevel("ChargeValue"), 2) & ")&nbsp;&nbsp;&nbsp;"
                    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

                    rsProgramLevel.MoveNext
                loop
            %>
            </p>

您可以将列表编译成字符串,就像这样...

Const ignoreCodes = " _04GIDBM _05GIDFM _03MIS(Q _06GIDMS _08EXHRM _10EXMKT _12EXTTH _15AFT _16HSC _18LTD _19EBM _17EXHSC "

将其添加到文件的最顶部(在任何 Option Explicit 命令之后)。如果您有新的代码要添加到它,只需确保它的两边都有 space。

然后测试一下...

If Instr(ignoreCodes, UCase(currentCodeValue)) = 0 Then
    Response.Write("<option value='" & currentCodeValue & "' ")
    If StrComp(strCurrentSelection, " " & currentCodeValue & " ", 1) = 0 then
        Response.Write " selected "
    End If
    Response.Write(">" & objListData(strDescriptionName) & "</option>")
End If

如果您进一步考虑这一点,则只需将列表包含在数据库中的冗余代码 table 中。

为简单起见,只需将发送 HTML 的代码包装在一个基本的 If..Then 语句中:

Dim currentCode

do until rsProgramLevel.EOF
    currentCode = rsProgramLevel("ProgramCode")
    If UCase(currentCode)<>"_BML7(B)" Then
          Response.Write "<input type=""radio"" name=""programcode"" onclick=""onProgramCode()"" "
          Response.Write "value=""" & currentCode & """ "
          if rsProgramLevel("ProgramCode") = strProgramCode then
              Response.Write "checked"
          end if
          Response.Write ">"
          Response.Write "&nbsp;"
          Response.Write rsProgramLevel("LevelDescription") & " (&pound;" & FormatNumber(rsProgramLevel("ChargeValue"), 2) & ")&nbsp;&nbsp;&nbsp;"
          Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"
    End If
    rsProgramLevel.MoveNext
loop