[PLUG-Devel] Javascript variable value into class parameter?
Mitch Frazier
mitch at linuxjournal.com
Thu Sep 10 13:36:56 MST 2009
I'm not JavaScript expert, but try something like:
var newval = 300;
...
document.getElementById("theclock").class.replace(/:\d+/,":"+newval);
That's an interesting way to invoke the clock:
... class="CoolClock:chunkySwissOnBlack:250" ...
Alan Dayley wrote:
> I, embedded developer and Scrum Master, am attempting to write
> javascript. Yes, the danger of error is high. However, your web
> pages are safe since this is a page for a specific and internal-only
> use.
>
> I am creating a page to have an official clock for the engineering
> team. Seems our meetings tend start a minute or two late. The
> discussion always leads to something like "Does anyone really know
> what time it is?" So I want to create the canonical answer to this
> question!
>
> I'm starting with this really cool "Cool Clock"
> http://randomibis.com/coolclock/. By slapping it on a page, it's good
> enough. Except, I want the clock to fill the screen of Firefox in
> full screen mode. Being a good programmer (just not with javascript)
> I want to solve the problem forever by making the page smart enough to
> resize the clock for the page it's on.
>
> The "class" parameter(?) has an argument to set the clock radius to a
> specified number of pixels. I have javascript that gets the current
> browser window size and determines what the radius should be. This
> radius value is stored in a javascript variable "clocksize."
>
> Now my problem: How do I get the value of this variable into the
> "class" statement of the following line?
>
> <canvas id="theclock" class="CoolClock:chunkySwissOnBlack:250"></canvas>
>
> I want the 250 in the above to be replaced by the value of the
> "clocksize" variable. Google searches give me all kinds of options
> like "document.write" and so on but I need to get the value into the
> string after the "class=" part of the canvas tag.
>
> Any tips or solutions from this group?
>
> Alan
> _______________________________________________
> PLUG-devel mailing list - PLUG-devel at lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
>
--
Mitch Frazier
Associate Editor/Web Editor, Linux Journal
http://www.linuxjournal.com
More information about the PLUG-devel
mailing list