2014-01-20 67 views
2

我正嘗試創建出現在選擇標記中的複選框列表。我搜索了很多文章,我沒有得到適當的輸出。請幫我解決這個問題。如何使用struts2在選擇框中添加複選框

<s:checkboxlist list = "%{cityList}" 
       name = "cityNo" 
        id = "cityNo" 
      cssClass = "margin-right margin-top required-field" 
      cssStyle = "width: 114px;height:30px" 
      headerKey = "0" 
      headerValue = "City" 
       listKey = "id" 
      listValue = "cityName" 
       onfocus = "getcitywithCountry(false);" /> 
+0

你應該指定如何這是行不通的。您遇到哪種錯誤等等...... –

+1

您想在選擇標籤中選擇每個選項的複選框嗎? –

+0

錯過了「在選擇標記」部分...然後:http://stackoverflow.com/questions/17714705/how-to-use-checkbox-inside-select-option –

回答

2

您不需要s:checkboxlist來實現您需要的功能。

下載以下

http://github.com/ehynds/jquery-ui-multiselect-widget/raw/1.13/src/jquery.multiselect.min.js 
http://github.com/ehynds/jquery-ui-multiselect-widget/raw/1.13/jquery.multiselect.css 

,並將它們添加到您的jsp。然後用s:select元素與multiple屬性設置爲true

<s:select id='your_id' multiple="true" name='your_name' key='key_from_properties_file' theme="xhtml" list='your_list' listKey='your_id' listValue='your_value' /> 
+0

中選擇每個選項的複選框,但它在標記中不起作用。請給我一些想法 –

+1

@UmarMuktharKadherIbrahim你是什麼意思,它不工作,你想做什麼? –

+0

我在jsp中添加了js和css,並且在我的ajax函數中添加了(「#cityNo」)。multiselect()。但它不起作用。是否有任何其他方式來完成這項任務請 –