2016-12-15 122 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