2015-08-17 56 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解決方案。 –

相關問題