对于VB脚本我是新手,我正在尝试使用onchange事件创建一个组合框。
这是我到目前为止的代码:
' Report Version
If FieldID = 36 Then
If IsLIXIJob Then
'first get the field id of the fields you want to hide or display
SQLQuery = "SELECT FieldID, FieldName FROM Fields WITH (NOLOCK) " & _
" WHERE [Table] = 'Valuations' AND " & _
" FieldName IN ('RiskTenderPriceDisplay', 'RiskProgressPaymentScheduleDisplay')"
Set LIXITBEFields = dbConn.Execute(SQLQuery)
TBEFieldsOn = ""
TBEFieldsOff = ""
If Not LIXITBEFields.EOF Then
Do While Not LIXITBEFields.EoF
TBEFieldsOn = TBEFieldsOn & "if (IsDefined ('StandardField_" & LIXITBEFields ("FieldID") & "')) $('StandardField_" & LIXITBEFields ("FieldID") & "').style.display = ''; " & vbCrLf
TBEFieldsOff = TBEFieldsOff & "if (IsDefined ('StandardField_" & LIXITBEFields ("FieldID") & "')) $('StandardField_" & LIXITBEFields ("FieldID") & "').style.display = 'none'; " & vbCrLf
LIXITBEFields.MoveNext ()
Loop
End If
LIXITBEFields.Close ()
Set LIXITBEFields = Nothing
End If
Select Case Output
Case 0
RunAtEnd = "AllFields(); " & TBEFieldsOff
Case 1
RunAtEnd = "StandardMode(); " & TBEFieldsOff
Case 2
RunAtEnd = "StrataMode();" & TBEFieldsOff
Case 3
RunAtEnd = "TBEMode();" & TBEFieldsOn
Case 4
RunAtEnd = "TBEUnitMode();" & TBEFieldsOn
Case 5
RunAtEnd = "RenoMode(); " & TBEFieldsOff
Case 6
RunAtEnd = "RenoUnitMode(); " & TBEFieldsOff
Case 7
RunAtEnd = "VacantLandMode();" & TBEFieldsOff
End Select
%>
<select name="ReportList" id="ReportList" onchange="ReportList_SelectedIndexChanged()">
<option value="All Fields">All Fields</option>
<option value="Existing Building">Existing Building</option>
<option value="xisting Building - Strata">Existing Building - Strata</option>
<option value="To Be Erected">To Be Erected</option>
<option value="To Be Erected - Strata">To Be Erected - Strata</option>
<option value="Extension & Renovation">Extension & Renovation</option>
<option value="Extension & Renovation - Strata">Extension & Renovation - Strata</option>
<option value="Vacant Land">Vacant Land</option>
</select>
<%
End If
我尝试制作一个包含Select Case的Sub语句,但它没有用。 我还在If语句之外创建了一个Private Sub,并在onboBox上调用了comboBox:
Private Sub ReportList_SelectedIndexChanged()
Dim selectedInd
selectedInd = ReportList.SelectedIndex
Dim selectedIt
selectedIt = ReportList.SelectedItem.Text
If selectedIt = "All Fields" Then
RunAtEnd = "AllFields(); " & TBEFieldsOff
End If
If selectedIt = "Existing Building" Then
RunAtEnd = "StandardMode(); " & TBEFieldsOff
End If
If selectedIt = "Existing Building - Strata" Then
RunAtEnd = "StrataMode();" & TBEFieldsOff
End If
If selectedIt = "To Be Erected" Then
RunAtEnd = "TBEMode();" & TBEFieldsOn
End If
If selectedIt = "To Be Erected - Strata" Then
RunAtEnd = "TBEUnitMode();" & TBEFieldsOn
End If
If selectedIt = "Extension & Renovation" Then
RunAtEnd = "RenoMode(); " & TBEFieldsOff
End If
If selectedIt = "Extension & Renovation - Strata" Then
RunAtEnd = "RenoUnitMode(); " & TBEFieldsOff
End If
If selectedIt = "Vacant Land" Then
RunAtEnd = "VacantLandMode();" & TBEFieldsOff
End If
End Sub
我真的坚持这一点。无论如何,我可以做这个工作吗?