我有表单面板,其中有20个复选框,我想获取表单提交上所有选中复选框的列表。可能有人会显示一些代码示例或告诉我应该怎么做?
<g:FormPanel ui:field="form">
<g:FlowPanel ui:field="flowPanel" width="580px" height="364px">
<g:HorizontalPanel width="460px" height="48px">
<g:Label height="33px">FC NAME:</g:Label>
<g:TextBox height="23px" ui:field="fcname"></g:TextBox>
<g:Button ui:field="button1">Button 1</g:Button>
<g:Button ui:field="button2">Button 2</g:Button>
</g:HorizontalPanel>
<g:Label>FCP Values</g:Label>
<g:VerticalPanel ui:field="verticalPanel">
<g:CheckBox ui:field="cb1" formValue="value 1">value 1</g:CheckBox>
<g:CheckBox ui:field="cb2" formValue="value 2">value 2</g:CheckBox>
<g:CheckBox ui:field="cb3" formValue="value 3">value 3</g:CheckBox>
<g:CheckBox ui:field="cb4" formValue="value 4">value 4</g:CheckBox>
<g:CheckBox ui:field="cb5" formValue="value 5">value 5</g:CheckBox>
<g:CheckBox ui:field="cb6" formValue="value 6">value 6</g:CheckBox>
</g:VerticalPanel>
<g:Button ui:field="submit">Submit</g:Button>
</g:FlowPanel>
</g:FormPanel>
</g:DecoratorPanel>
</g:HTMLPanel>
答案 0 :(得分:0)
第一个解决方案:声明视图中的所有复选框,并在发生提交事件时读取所有复选框。
第二个解决方案:浏览所有verticalPanel
个孩子在发生提交事件时将它们投射到CheckBox。