【发布时间】:2015-06-25 12:50:26
【问题描述】:
我需要在 S2 中创建多个复选框,如下所示。
使用此代码我只得到一个复选框
public class EmployeeListBean {
private String empCode = null;
private String empName = null;
public EmployeeListBean(String empCode,String empName)
{
//constructor
}
//setter and getter methods
}
在行动课上
public ArrayList<EmployeeListBean> getListOfEmployees()
{
return listOfEmployees;
}
在执行()中
listOfEmployees = new ArrayList<EmployeeListBean>();
listOfEmployees.add(new EmployeeListBean("1", "Smith"));
在 JSP 中,
<s:iterator value="listOfEmployees">
<s:checkbox name="someselectedname" label="%{empName}" fieldValue="%{empCode}"/><br/>
</s:iterator>
我按照正常的方式。这里我想在三个复选框中只选择一个复选框。所以我们可以在 JS 或 Jquery 中完成。在 HTML 中,就像
<label>abc: </label>
<input type="checkbox" name="ballet" />
<input type="checkbox" name="ballet" />
<input type="checkbox" name="ballet" />
<br/>
<label>def: </label>
<input type="checkbox" name="ballet1" />
<input type="checkbox" name="ballet1" />
<input type="checkbox" name="ballet1" />
但我想要以上格式。如何在 S2 中执行此操作。
【问题讨论】:
-
如果您只想选择三个复选框中的一个,那么我建议使用单选按钮而不是复选框。