Set of functions to generate Bootstrap controls as strings. Controls available are Button, Inputbox, listbox and textarea along with or without label using Bootstrap 4.1 and Font-Awesome icons.
Can pass btn classes, and additional information, like if a button is for a modal, disabled, or regular, if a confirmation message is needed or not, if a control is read-only or not, also can pass width of grid for a label if label is needed.
ANBSListBox can accept either 1D ANStrArray, where item ID is same as Item name, or 2D ANStrArray where 1 for Item value and second for item name.
Functions are:
ANBSButton
ANBSInputBox
ANBSTextArea
ANBSListBox
:: Update 2018-06-30
Set2
Set3
Function ANBSButton(URL_Or_ModalID_Or_Disabled, Caption, Classes, FAIcon, ConfirmMGS, DataParameters)
' If URL_Or_ModalID_Or_Disabled = some url, it will be active regular link
' If url is provided and ConfirmMGS is not blank, a confirm message will ask user before that link is executed
' If URL_Or_ModalID_Or_Disabled = "", disabled button
' If URL_Or_ModalID_Or_Disabled = "#modal", then it will be a modal link, needs to have a modalbox setup
' DataParameters must be like " data-1="rr" data-4="55"
Diss = ""
ConfDelete = ""
If URL_Or_ModalID_Or_Disabled = "" Or UCase(URL_Or_ModalID_Or_Disabled) = "D" Then Diss = " disabled=""disabled"" "
If ConfirmMGS = 1 Then ConfDelete = " onclick=""return confirm('" & ConfirmMGS & "');"" "
Rett = " <a href=""" & URL_Or_ModalID_Or_Disabled & """ class=""btn " & Classes & """ " & Diss & " "
If Left(URL_Or_ModalID_Or_Disabled, 1) = "#" Then
Rett = " <a href=""javascript:void(0);"" data-toggle=""modal"" data-target=""" & URL_Or_ModalID_Or_Disabled & """ "
Rett = Rett & "class=""btn " & Classes & """ " & DataParameters & " "
End If
ANBSButton = Rett & ConfDelete & " > <i class=""" & FAIcon & """ > </i >" & Caption & " </a >" & vbcrlf
End Function
Function ANBSInputBox(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType)
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
' BType = "password", "Text", ...
' Using Bootstrap 4, label width = 3, input box width = 9
Rett = ""
ReadOnly = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If BType = "" Then BType = "text"
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <input type=""" & BType & """ id=""" & BName & """ name=""" & BName & """ "
Rett = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
ANBSInputBox = Rett & "value=""" & BValue & """ " & ReadOnly & " >" & Div2Close
End Function
Function ANBSTextArea(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, RowsHeight)
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
' RowsHeight is the height of textarea in rows
Rett = ""
ReadOnly = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If fix(RowsHeight) < 1 Then RowsHeight = 5
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <textarea name=""" & BName & """ id=""" & BName & """ "
Rett = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
ANBSTextArea = Rett & ReadOnly & " rows=""" & RowsHeight & """ >" BValue & " </textarea >" & Div2Close
End Function
Function ANBSListBox(BName, BList, BCaption, ReadOnly1_ReadWrite2, LabelWidth, InitialSelection, With1stSelection)
' BList is 2D list of ID and Value with SepaCol and SepaRow as separaters
' If BList is 1D (no SepaRow found), then items values will be same as items names
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of Listbox = 12 - LabelWidth (bootstrap grid width)
' With1stSelection = 1 to have 1st item having [Please select] with value of 'No'
' InitialSelection can be either the ID of active item or the full text value
' Needs CutString, CutString3
' Needs SepaCol and SepaRow as separaters
Rett = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <select name=""" & BName & """ id=""" & BName & """ class=""form-control"" "
Rett = Rett & ReadOnly & " >" & vbcrlf
If With1stSelection = 1 Then
Rett = Rett & " <option value=""none"" >[Please Select] </option >" & vbcrlf
End If
X1 = 0
If InStr(1, BList, SepaRow) > 0 Then
For Each OpItem in Split(BList, SepaRow)
OpItemID = CutString3(OpItem, 1, SepaCol)
OpItemCap = CutString3(OpItem, 2, SepaCol)
Active1 = ""
X1 = X1+1
If IsNumeric(InitialSelection) Then
If Fix(InitialSelection) = X1 Then Active1 = " selected "
Else
If UCase(InitialSelection) = UCase(OpItemID) Then Active1 = " selected "
End If
Rett = Rett & " <option value=""" & OpItemID & """ " & Active1 & " >" & OpItemCap & " </option >" & vbcrlf
Next
Else
For Each OpItem in Split(BList, SepaCol)
Active1 = ""
X1 = X1 + 1
If IsNumeric(InitialSelection) Then
If Fix(InitialSelection) = X1 Then Active1 = " selected "
Else
If UCase(InitialSelection) = UCase(OpItem) Then Active1 = " selected "
End If
Rett = Rett & " <option value=""" & OpItem & """ " & Active1 & " >" & OpItem & " </option >" & vbcrlf
Next
End If
ANBSListBox = Rett & " </select >" & Div2Close
End Function
' If URL_Or_ModalID_Or_Disabled = some url, it will be active regular link
' If url is provided and ConfirmMGS is not blank, a confirm message will ask user before that link is executed
' If URL_Or_ModalID_Or_Disabled = "", disabled button
' If URL_Or_ModalID_Or_Disabled = "#modal", then it will be a modal link, needs to have a modalbox setup
' DataParameters must be like " data-1="rr" data-4="55"
Diss = ""
ConfDelete = ""
If URL_Or_ModalID_Or_Disabled = "" Or UCase(URL_Or_ModalID_Or_Disabled) = "D" Then Diss = " disabled=""disabled"" "
If ConfirmMGS = 1 Then ConfDelete = " onclick=""return confirm('" & ConfirmMGS & "');"" "
Rett = " <a href=""" & URL_Or_ModalID_Or_Disabled & """ class=""btn " & Classes & """ " & Diss & " "
If Left(URL_Or_ModalID_Or_Disabled, 1) = "#" Then
Rett = " <a href=""javascript:void(0);"" data-toggle=""modal"" data-target=""" & URL_Or_ModalID_Or_Disabled & """ "
Rett = Rett & "class=""btn " & Classes & """ " & DataParameters & " "
End If
ANBSButton = Rett & ConfDelete & " > <i class=""" & FAIcon & """ > </i >" & Caption & " </a >" & vbcrlf
End Function
Function ANBSInputBox(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType)
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
' BType = "password", "Text", ...
' Using Bootstrap 4, label width = 3, input box width = 9
Rett = ""
ReadOnly = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If BType = "" Then BType = "text"
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <input type=""" & BType & """ id=""" & BName & """ name=""" & BName & """ "
Rett = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
ANBSInputBox = Rett & "value=""" & BValue & """ " & ReadOnly & " >" & Div2Close
End Function
Function ANBSTextArea(BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, RowsHeight)
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of inputbox = 12 - LabelWidth (bootstrap grid width)
' RowsHeight is the height of textarea in rows
Rett = ""
ReadOnly = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If fix(RowsHeight) < 1 Then RowsHeight = 5
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <textarea name=""" & BName & """ id=""" & BName & """ "
Rett = Rett & "placeholder=""" & RemoveHTML(BCaption) & """ class=""form-control"" "
ANBSTextArea = Rett & ReadOnly & " rows=""" & RowsHeight & """ >" BValue & " </textarea >" & Div2Close
End Function
Function ANBSListBox(BName, BList, BCaption, ReadOnly1_ReadWrite2, LabelWidth, InitialSelection, With1stSelection)
' BList is 2D list of ID and Value with SepaCol and SepaRow as separaters
' If BList is 1D (no SepaRow found), then items values will be same as items names
' LabelWidth = width of label = 0 to 11 (bootstrap grid width), XWidth = 0 means no label
' Width of Listbox = 12 - LabelWidth (bootstrap grid width)
' With1stSelection = 1 to have 1st item having [Please select] with value of 'No'
' InitialSelection can be either the ID of active item or the full text value
' Needs CutString, CutString3
' Needs SepaCol and SepaRow as separaters
Rett = ""
Div2Close = vbcrlf
LabelWidth = Fix(LabelWidth)
If Fix(ReadOnly1_ReadWrite2) = 1 Then ReadOnly = " readonly "
If LabelWidth > 0 Then
Rett = Rett & " <div class=""form-group row"" >" & vbcrlf
Rett = Rett & " <label for=""" & BName & """ class=""col-form-label col-md-" & LabelWidth & """ >"
Rett = Rett & BCaption & " </label >" & vbcrlf
Rett = Rett & " <div class=""col-md-" & 12 - LabelWidth & """ >" & vbcrlf
Div2Close = " </div > </div >" & vbcrlf
End If
Rett = Rett & " <select name=""" & BName & """ id=""" & BName & """ class=""form-control"" "
Rett = Rett & ReadOnly & " >" & vbcrlf
If With1stSelection = 1 Then
Rett = Rett & " <option value=""none"" >[Please Select] </option >" & vbcrlf
End If
X1 = 0
If InStr(1, BList, SepaRow) > 0 Then
For Each OpItem in Split(BList, SepaRow)
OpItemID = CutString3(OpItem, 1, SepaCol)
OpItemCap = CutString3(OpItem, 2, SepaCol)
Active1 = ""
X1 = X1+1
If IsNumeric(InitialSelection) Then
If Fix(InitialSelection) = X1 Then Active1 = " selected "
Else
If UCase(InitialSelection) = UCase(OpItemID) Then Active1 = " selected "
End If
Rett = Rett & " <option value=""" & OpItemID & """ " & Active1 & " >" & OpItemCap & " </option >" & vbcrlf
Next
Else
For Each OpItem in Split(BList, SepaCol)
Active1 = ""
X1 = X1 + 1
If IsNumeric(InitialSelection) Then
If Fix(InitialSelection) = X1 Then Active1 = " selected "
Else
If UCase(InitialSelection) = UCase(OpItem) Then Active1 = " selected "
End If
Rett = Rett & " <option value=""" & OpItem & """ " & Active1 & " >" & OpItem & " </option >" & vbcrlf
Next
End If
ANBSListBox = Rett & " </select >" & Div2Close
End Function
URL_Or_ModalID_Or_Disabled, Caption, Classes, FAIcon, ConfirmMGS, DataParameters
Or
BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType
Or
BName, BValue, BCaption, ReadOnly1_ReadWrite2, LabelWidth, BType
Views 13,199
Downloads 1,561
CodeID
DB ID
ANmarAmdeen
614
Revisions
v6.0
Saturday
March
27
2021