Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] [OT] Looking for Javascript 3-toggle button



On Sat, 13 Feb 2010 00:23:40 +0900, Dave M G <dave@example.com> wrote:

> I think I must be using the wrong terminology, because I can't believe
> this wheel has not been invented before.

It is pretty trivial, which is probably why nobody's thought it worthwhile
making a souped up project of it. This off the top of my head:

<script language="javascript" type="text/javascript">
<!--
var colors = new Array("#ffff00","#ff0000","#00ff00");

function buttonClicked(buttonid) {
	var newcolor = colors.shift();
	colors.push(newcolor);
	var ctrl = document,getElementById(buttonid);
	button.styles.backgroundColor = newcolor;
}
// -->
</script>


Then, elsewhere in your HTML:

<input type="button" id="threestate" class="whatever"
       onclick="buttonclicked('threestate')"
       style="background-color: #00ff00;"
       value="whatever" />

-- 
G. Stewart - gstewart@example.com

It's always a long day; 86400 doesn't fit into a short.

Attachment: pgpWSczt7PYkM.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links