2015-08-17 55 views
0

我正在使用VB中的一个经典ASP页面,这两个页面我都不太熟悉。我试图改变这个从动态值复选框列表

enter image description here

这个

enter image description here

这应该是非常简单的,除了它看起来像名单是动态的,它绊倒了我。

<% 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 %> 
+1

你有什么特别的麻烦? – Bond

+0

我不知道如何把我在那里变成更像这样的东西

This is checkbox
This is checkbox
This is checkbox
This is checkbox
This is checkbox
This is checkbox
This is checkbox

+0

http://stackoverflow.com/questions/7280389/scrollable-box-containing-list-of-checkboxes-in-html –

回答

3

你需要得到的标记与此类似:

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

你最有可能有一个动态列表(或可能记录)。你可以通过它循环。 您可以根据需要调整此解决方案。 (用任何值代替i)

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

要获得的复选框列表中,你应该使用CheckedListBox控制。

ASPX标记:

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

在后台代码:

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 

要获得滚动条,你应该ScrollBars财产围住CheckedListBoxPanel设置为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> 
+0

谢谢,因为这是经典的asp我不确定如果我可以使用asp控件。 –

+2

好吧..你把vb.net和classic-asp标签都混淆了。我将添加经典的asp解决方案。 –

相关问题