Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Date: Sun, 14 Feb 2010 16:30:38 +0000
- From: Godwin Stewart <gstewart@example.com>
- Subject: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- References: <4B75727C.50501@example.com> <20100212154700.b2e5825e.gstewart@example.com> <4B777835.20804@example.com> <20100214110510.1f577b53.gstewart@example.com> <20100214112157.cef91bdc.gstewart@example.com> <4B78012A.10004@example.com> <20100214140416.3f7a1fda.gstewart@example.com> <4B78140A.8080108@example.com> <20100214152147.d70b7890.gstewart@example.com> <4B781C3D.4050100@example.com>
On Mon, 15 Feb 2010 00:52:29 +0900, Dave M G <dave@example.com> wrote: > Any idea what's missing? You've also done completely away with referencing the control that's actually been clicked on. In the onclick method of the button, you're passing the id of the button itself ("radar") to the buttonClicked() function. Within that function, the control is referred to as "threestate", yet you're explicitly referring to "radar" within the function. This means that, if you have multiple instances of your three-state control in the page, whenever you click on any one of them it's "radar" that's going to be altered. Change the line within your function so that it grabs the elementById of the button that's passed to it in its arguments: var ctrl = document.getElementById(threestate); Also, another thing I've just thought of that will need doing if there are multiple controls like this one is that each one will need its own array of backgrounds otherwise each click will cycle through the backgrounds instead of it happening independently for each control. Change the definition of the array to: var images = new Array(); images['radar'] = new Array( "yellow", "red", "green" ); And change the buttonClicked() function so that it goes like this: var newimage = images[threestate].shift(); images[threestate].push(newimage); var ctrl = document.getElementById(threestate); ctrl.style.backgroundImage = newimage + ".png"; -- G. Stewart - gstewart@example.com Never let your schooling interfere with your education!Attachment: pgpAQwc68BKWD.pgp
Description: PGP signature
- Follow-Ups:
- References:
- [tlug] [OT] Looking for Javascript 3-toggle button
- From: Dave M G
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Dave M G
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Dave M G
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Dave M G
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Next by Date: Re: [tlug] [OT] Looking for Javascript 3-toggle button [SOVLED]
- Previous by thread: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Next by thread: Re: [tlug] [OT] Looking for Javascript 3-toggle button [SOVLED]
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links