Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > determine checkbox most recently checked

Reply
Thread Tools

determine checkbox most recently checked

 
 
pleaseexplaintome@yahoo.com
Guest
Posts: n/a
 
      12-18-2006
Hi I need to determine the most recent check box that was checked.
Let's say I have 5 checkboxes. CB 1 is checked and I then check CB 5.
How do I know CB 5 was just checked, regardless of the fact CB 1 is
checked? I don't care that CB 1 is checked, so looping thru the CB's
won't help here. I cannot use radio buttons since I need unique names
for the checkboxes. Thanks

 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      12-18-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Hi I need to determine the most recent check box that was checked.
> Let's say I have 5 checkboxes. CB 1 is checked and I then check CB 5.
> How do I know CB 5 was just checked, regardless of the fact CB 1 is
> checked? I don't care that CB 1 is checked, so looping thru the CB's
> won't help here. I cannot use radio buttons since I need unique names
> for the checkboxes. Thanks


Hi,

Simply do it yourself.
Add an eventhandler for onClick and store the value in a global var.

Regards,
Erwin Moller
 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      12-18-2006
(E-Mail Removed) said:
>
>Hi I need to determine the most recent check box that was checked.
>Let's say I have 5 checkboxes. CB 1 is checked and I then check CB 5.
>How do I know CB 5 was just checked, regardless of the fact CB 1 is
>checked? I don't care that CB 1 is checked, so looping thru the CB's
>won't help here. I cannot use radio buttons since I need unique names
>for the checkboxes. Thanks


Why do you believe that you need unique names for the boxes?
Give them all the same name, but different values.


--

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      12-18-2006
(E-Mail Removed) said the following on 12/18/2006 8:45 AM:
> Hi I need to determine the most recent check box that was checked.
> Let's say I have 5 checkboxes. CB 1 is checked and I then check CB 5.
> How do I know CB 5 was just checked, regardless of the fact CB 1 is
> checked? I don't care that CB 1 is checked, so looping thru the CB's
> won't help here. I cannot use radio buttons since I need unique names
> for the checkboxes. Thanks
>


onclick="var lastClicked=this.name"

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      12-18-2006
In comp.lang.javascript message <(E-Mail Removed)>,
Mon, 18 Dec 2006 10:48:17, Randy Webb <(E-Mail Removed)> wrote:
>(E-Mail Removed) said the following on 12/18/2006 8:45 AM:
>> Hi I need to determine the most recent check box that was checked.
>> Let's say I have 5 checkboxes. CB 1 is checked and I then check CB 5.
>> How do I know CB 5 was just checked, regardless of the fact CB 1 is
>> checked? I don't care that CB 1 is checked, so looping thru the CB's
>> won't help here. I cannot use radio buttons since I need unique names
>> for the checkboxes. Thanks
>>

>
>onclick="var lastClicked=this.name"


That should indicate the last one clicked, not the last one checked.

It seems immoral to have a var there; lastClicked should be initialised
by var lastClicked = null or similar.

I get the underlying action that the OP seems to need with

<input type=checkbox onclick="if (this.checked) alert(9)">
and
<input type=checkbox onclick="if (this.checked) window.status++">

It's a good idea to read the newsgroup and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      12-19-2006
Dr J R Stockton wrote on 19 dec 2006 in comp.lang.javascript:

> <input type=checkbox onclick="if (this.checked) window.status++">


window.status won't show in IE7


>> onclick="var lastClicked=this.name"


I would prefer saving an object pointer:

<script type='text/javascript'>
var lastClicked = null;
</script>

<input type='checkbox'
onclick = 'if (this.checked) lastClicked = this'>

<button
onclick = 'lastClicked.checked = false'>
Clear only the last checked checkbox
</button>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBox Checked=false when checked in DataList yurps ASP .Net 1 02-29-2008 01:08 PM
MRU (most recently used) List To Be Found Where ? Robert11 Computer Support 5 03-24-2005 08:12 AM
MRU (most recently used) Lists Quest. ? Robert11 Computer Support 2 02-08-2005 08:17 PM
Have You Checked Yours Recently ? IBM AC Adapter Bb NZ Computing 0 09-05-2004 11:08 PM
Checkbox - database checkbox, if checked gives value of 1 .. how to sum ? randy Perl Misc 13 11-01-2003 05:39 AM



Advertisments