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 13:12:37 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- References: <4B75727C.50501@example.com> <20100212154700.b2e5825e.gstewart@example.com>
- User-agent: Thunderbird 2.0.0.23 (X11/20090817)
Godwin, Thank you so much for the code! I guess it is a small and trivial matter, but I'm still very much in the copy-and-paste stage of using Javascript, so for me it's a huge leap forward. The code as provided didn't work right away, so I tried to modify it a bit, and also customize it, but I'm not sure what is holding it back. Some of the changes I made beyond changing some names was: there was a comma where a period should be, I changed the switcher to use images instead of colours, and I moved the Javascript to be in a separate file. Here is the Javascript part as it now is: var images = new Array( "green.png", "yellow.png", "red.png"); (function buttonClicked(threestate) { var newimage = images.shift(); images.push(newimage); var ctrl = document.getElementById(radar); button.styles.backgroundImage = newimage; })(); And here it is in the HTML (extraneous HTML ommitted): <head> <script type="text/javascript" src="javascript/button_3_stage.js"></script> </head> <input type="button" id="radar" onclick="buttonclicked('threestate')" style="background-image: url(images/green.png);width:53px;height:53px;border:0;" value="" /> I use Firebug to debug Javascript, and it's saying: radar is not defined buttonClicked(Object { name="threestate"})button_3_stage.js (line 12) button_3_stage.js()button_3_stage.js (line 9) var ctrl = document.getElementById(radar); I thought I defined "radar" because that is the ID of the button...? Am I mixed up about how the Javascript identifies which button to use? Thank you for any advice. -- Dave M G
- Follow-Ups:
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Darren Cook
- Re: [tlug] [OT] Looking for Javascript 3-toggle button
- From: Godwin Stewart
- 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
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Question regarding TV Card for Linux;
- Next by Date: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Previous by thread: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Next by thread: Re: [tlug] [OT] Looking for Javascript 3-toggle button
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links