0

I am working on a classic ASP page in VB both of which I am not hugely familiar with. I am trying change this

enter image description here

to this

enter image description here

Which should be pretty straight forward except it looks like the list is dynamic and its tripping me up.

 <% sendtomenu = sendtomenu + "<option value = " & trim(Recordset2.Fields.Item("linkfile").Value) & ">" & trim(Recordset2.Fields.Item("description").Value) & "</option>" %>


    <td width="231" height="25"> <select name="sendto" size="2" multiple class="blacktype" id="sendto">
            <% Response.write sendtomenu %>
user692942
  • 14,779
  • 6
  • 66
  • 157
Leonardo Wildt
  • 2,096
  • 3
  • 23
  • 45

2 Answers2

3

You need to get markup similar to this:

<div id="CheckedListBox1" style="border-width:1px;border-style:Solid;height:100px;width:300px;overflow-y:scroll;padding:2px;">
    <input type="checkbox" id="cb1" /><label for="cb1">This is checkbox1</label><br>
    <input type="checkbox" id="cb2" /><label for="cb2">This is checkbox2</label><br>
    <input type="checkbox" id="cb3" /><label for="cb3">This is checkbox3</label><br>
    ... 
</div>

You most likely have a dynamic list (or probably recordset). You can loop thru it. You can adapt this solution as per your needs. (Replace i with whatever values.)

<div id="CheckedListBox1" style="border-width:1px;border-style:Solid;height:100px;width:300px;overflow-y:scroll;padding:2px;">
    <% For i = 1 To 10 %>
        <input type="checkbox" id=cb<% =i %> value=<% =i %> />
        <label for=cb<% =i %>>This is checkbox<% =i  %></label><br>
    <% Next %>
</div>
Pradeep Kumar
  • 6,414
  • 4
  • 18
  • 45
0

To get the checkboxes list, you should use the CheckedListBox control.

aspx markup:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" BorderStyle="Solid" BorderWidth="1px" ></asp:CheckBoxList>

In the code-behind:

Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    '' this is the most simplest example of adding items. you may use databinding etc.
    CheckBoxList1.Items.Add("This is checkbox 1")
    CheckBoxList1.Items.Add("This is checkbox 2")
    CheckBoxList1.Items.Add("This is checkbox 3")
    CheckBoxList1.Items.Add("This is checkbox 4")
    CheckBoxList1.Items.Add("This is checkbox 5")
    CheckBoxList1.Items.Add("This is checkbox 6")
    CheckBoxList1.Items.Add("This is checkbox 7")
    CheckBoxList1.Items.Add("This is checkbox 8")
    CheckBoxList1.Items.Add("This is checkbox 9")
End Sub

To get the scrollbars, you should enclose the CheckedListBox in a Panel with ScrollBars property set to Vertical

<asp:Panel ID="Panel1" runat="server" BorderStyle="Solid" BorderWidth="1px" ScrollBars="Vertical" Width="300px" Height="100px">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server" ></asp:CheckBoxList>
</asp:Panel>
Pradeep Kumar
  • 6,414
  • 4
  • 18
  • 45