显示和隐藏与选中复选框相关的表列 [英] Show and Hide Table Column related to checked checkboxes

查看:80
本文介绍了显示和隐藏与选中复选框相关的表列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我有多个选项复选框


[HTML]< input type =''复选框''名称=''coffee''id =''col1''value =''地址''/>

< input type =''复选框''name ='''coffee''id = ''col2''value =''名称''/>

< input type =''复选框''name =''coffee''id =''col3''value =' 'ID''/>

< input type =''复选框''name =''coffee''id =''col4''value =''UserName''/>

< input type =''checkbox''name =''coffee''id =''col5''value =''Code''/>

[ / HTML]

想要将它们存储在数组中。提交按钮。

然后隐藏并显示关于复选框选择的表格列。即选中的复选框将显示表格中的列将隐藏。


[HTML]< td id =" col1">地址< / td>

将TD ID = QUOT; COL2">名称< / TD>

将TD ID = QUOT; COL3"> ID< / TD>

< TD ID = QUOT; COL4">用户名< / TD>

将TD ID = QUOT; COL5">代码< / TD> [/ HTML]


因此,如果复选框为名称,则为和ID检查比仅显示名称列的列。和ID休息将隐藏但将在提交按钮时完成

Hi!

I have a multiple selection of checkboxes

[HTML]<input type=''checkbox'' name=''coffee'' id=''col1'' value=''Address''/>
<input type=''checkbox'' name=''coffee'' id=''col2'' value=''Name''/>
<input type=''checkbox'' name=''coffee'' id=''col3'' value=''ID''/>
<input type=''checkbox'' name=''coffee'' id=''col4'' value=''UserName''/>
<input type=''checkbox'' name=''coffee'' id=''col5'' value=''Code''/>
[/HTML]
Want to store them in array. On submit of button.
Then hide and show the table column with respect to selection of checkboxes. i.e. selected checkbox will show that columns in table resat will hide.

[HTML]<td id="col1">Address</td>
<td id="col2">Name</td>
<td id="col3">ID</td>
<td id="col4">UserName</td>
<td id="col5">Code</td>[/HTML]

thus if checkbox for "Name" and "ID" are checked than it will show the Columns only for "Name" and "ID" rest will hide but will be done on submit of the button

推荐答案

为了正确解释,您的ID必须是唯一的。在IE中你会得到它(大部分时间)但不会在FF中。


ROnald
For a correct interpretation your ID''s must be unique. In IE you will get away with it (most of the time) but not in FF.

ROnald


如何继续使用代码与表格单元格的修改ID相同,即。 tcol1,tcol2。

[HTML]< form>

< input type =''复选框''name =''coffee''id =''col1' 'value =''地址''/>

< input type =''复选框''name =''coffee''id =''col2''value =''名称'' />

< input type =''复选框''name =''coffee''id =''col3''value =''ID''/>

< input type =''复选框''name =''coffee''id =''col4''value =''UserName''/>

< input type = ''复选框''name =''coffee''id =''col5''value =''代码''/>

< input type =''button''onclick =' 'show()''value =''保存''>

< / form>


< td id =" tcol1"> ;地址< / TD>

将TD ID = QUOT; tcol2">名称< / TD>

将TD ID = QUOT; tcol3"> ID< ; / td>

< td id =" tcol4"> UserName < / td>

< td id =" tcol5">代码< / td>

[/ HTML]

Onclick在保存按钮我应该能够存储选中的复选框,然后显示表中的相关列,其余隐藏。在下一个循环中,修改后的已检查复选框再次存储了新的和之前已清理的,因此显示了受尊重的列。
How can i proceed with the code for the same with the modified id for table cell ie. tcol1, tcol2.
[HTML]<form>
<input type=''checkbox'' name=''coffee'' id=''col1'' value=''Address''/>
<input type=''checkbox'' name=''coffee'' id=''col2'' value=''Name''/>
<input type=''checkbox'' name=''coffee'' id=''col3'' value=''ID''/>
<input type=''checkbox'' name=''coffee'' id=''col4'' value=''UserName''/>
<input type=''checkbox'' name=''coffee'' id=''col5'' value=''Code''/>
<input type=''button'' onclick=''show()'' value=''Save''>
</form>

<td id="tcol1">Address</td>
<td id="tcol2">Name</td>
<td id="tcol3">ID</td>
<td id="tcol4">UserName</td>
<td id="tcol5">Code</td>
[/HTML]
Onclick on Save button I should be able to store the checked checkbox an then show the related columns in table, rest hidden. In next cycle the modified checked checkboxes again stored new one and previous cleened and thus the show respected column.


如果您要提交表单,您可能甚至不需要JavaScript 。页面是否会刷新?
You might not even need JavaScript for this if you''re going to submit the form. Is the page going to be refreshed?


这篇关于显示和隐藏与选中复选框相关的表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆