如何设置相互影响的复选框组 [英] How to set up groups of checkboxes which affect each other

查看:135
本文介绍了如何设置相互影响的复选框组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不明的标题很抱歉,但很难把我想做的几个字缩小。这正是我想要做的:

Sorry for the ambiguous title, but it's quite hard to condense what I'm trying to do into a few words. Here's exactly what I'm trying to do:

我想有一系列的复选框组。一个是性别,带有男性和女性的复选框,一个是区域,带有北,东,南和西等复选框。

I want to have a series of groups of checkboxes. One would be gender, with checkboxes for Male and Female, one would be Region, with checkboxes for North, East, South and West and so on.

允许用户选择说,男性或女性,但一旦他们在另一个组的复选框中勾选例如任何区域复选框,其所有其他组的所有先前检查都将被删除。

The aim is to allow the user to select say, Male or Female, but as soon as they put a check in a checkbox of another group e.g. any of the Region checkboxes, all of their previous 'checks' from all other groups are removed.

这一点是只允许用户从一组复选框中选择

The point is to only allow the user to select from one group of checkboxes at a time.

我只想到检查使用javascript在点击时标记了哪些复选框,但是想知道是否有更简单的方法,我可能会缺少。

I can only think of checking which checkboxes have been marked on click using javascript, but was wondering if there was a simpler way which I may be missing.

我也认为每个群组的隐藏单选按钮可能有效。

I've also thought that maybe a hidden radio button for each group could work.

一个更优雅的解决方案,我渴望听到它。

If anyone has a more elegant solution I'm eager to hear it.

推荐答案

管理来从fearofawhack行星的一点帮助。看起来很简单。

Managed to figure it out with a little help from fearofawhack planet. Seems really simple now.

指向JSFiddle的链接 http: //jsfiddle.net/aeeN4/

Heres a link to the JSFiddle http://jsfiddle.net/aeeN4/

这篇关于如何设置相互影响的复选框组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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