Meaningless Drivel is fun!
The moose likes HTML, CSS and JavaScript and the fly likes Most recently selected checkbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Most recently selected checkbox" Watch "Most recently selected checkbox" New topic

Most recently selected checkbox

J Chung

Joined: Jan 25, 2006
Posts: 9

I have a bunch of checkboxes, and I have an alert that informs the user when he has selected the maximum number of selections. So say my maximum is six: once the user clicks on his sixth checkbox, the alert appears.

What I'm trying to do is to prevent the user from selecting a seventh checkbox unless he deselects one of the six already selected. I can retrieve all the checkbox elements as one array and access each checkbox via its index, but how can I reliably retrieve the index of the most recently selected checkbox (i.e., the index of the seventh checkbox so I can set its "checked" attribute to "false")?
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385

I agree. Here's the link:
subject: Most recently selected checkbox
It's not a secret anymore!