2016-12-15 56 views
0

我问了几个月后如何隐藏从数据库中拉出的经典ASP页面上的一些下拉选项,以便用户无法选择这些选项。但现在剩余的选项之一出现了3个收音机选项。我必须删除其中的一个选项。根据Chrome,我需要删除的选项叫做value="_BML7(B)"隐藏ASP经典页面上的单选按钮选项

上次我将以下代码插入到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 

我真的可以使用这个帮助,并提前感谢大家的帮助!我不是很擅长经典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> 
+2

是否有特定的原因,你不能排除在数据库级不需要的代码?即在它们进入你的ASP页面之前? – Martha

+0

相信与否我无法访问数据库,因此我不得不这样做。 – user2219472

+0

此代码发送下拉列表选项。这与你所要求的无关。请分享您产生您提及的单选按钮的实际代码,我们可以尝试帮助您改变它。 –

回答

1

为了使这个简单的,只是包装的代码与基本If..Then声明发送HTML:

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 
+0

谢谢。它看起来差不多的工作,但随后上了车“800a01f4” 变量未定义的pageMicrosoft VBScript运行时错误如下:“currentCode” /c_studentreg3_new.asp,线578 – user2219472

+0

@ user2219472看到编辑,你需要声明它。 –

+0

你是魔法暗影精灵!非常感谢你解决了这个问题。你太棒了,我在你的债务!谢谢 – user2219472

2

你可以编译列表转换为字符串,像这样......

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

将它添加到文件的最顶部(任何Option Explicit命令后)。如果你有新的代码添加到它只是确保有一个空间的任何一方。

然后,只需对照它...

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 

如果你想想这进一步,那么只需在数据库中的冗余代码表列表。

+0

任何机会,请你可以解释我可以如何应用你的建议。我应该插入你让我进入include.asp文件? – user2219472

+0

@ user2219472这很令人担忧......你甚至知道VBScript吗? Paul为排除列表提供了一个更简单的方法,你只需要用当前的'If'语句替换这个。 – Lankymart

+0

我在尽我所能。但是,谢谢。在这个时候,我不确定第一部剧本的位置。我会很感激你对我的耐心。 VB脚本不是我的东西。谢谢你到目前为止 – user2219472

相关问题