2014-01-20 123 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()。但它不起作用。是否有任何其他方式来完成这项任务请 –