[Javascript] Changing dom values from HTML clicks
Skip Evans
skip at bigskypenguin.com
Thu Jun 5 20:22:27 CDT 2008
Hey all,
Okay, I've actually cut out the call to the JS
file altogether, and now just have this in the
HTML form with the color selector.
<a href="#"
onclick="document.getElementById('leftcontent').style.background=theme_form.color.value;">
Left Block
Background</a>
So with this it looks like I can simply have one
link with the onclick call for each style element
I want the user to be able to change.
Does this look like a sound strategy?
Thanks gobs!
Skip
Skip Evans wrote:
> Hey all,
>
> I am creating this "theme builder" module to
> change the look and feel through the DOM on the
> fly and then record this into a database to then
> create a custom CSS file.
>
> The way I am doing it now, just to test it out, I
> know is not the best way and that there is a
> better way, but I could use some guidance here.
>
> Basically, I downloaded the color selector tool at:
>
> http://ecritters.biz/colorselector/
>
> which I then use to select a color and send the
> value to JS code to set a value in the DOM. Here
> are the code snippets that do the work, but I know
> there must be a better way.
>
> First, after the user selects a color, they click
> a link to send this value to the JS code like this:
>
> <a href="#"
> onclick="set_theme_property(theme_form.color.value,'left_block_background');">
> Left Block
> Background</a>
>
> Then in the JS, I use a switch statement to
> determine which value is being set, and then...
>
> case 'left_block_background':
> var object=document.getElementById('leftcontent');
> object.style.background=val;
> break;
>
> ...does the work.
>
> What is the right way to do this? Seems to me
> there should be way to send the property that is
> being set from the HTML that would not require a
> big switch statement for every property.
>
> Thanks much!
>
--
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, WI 53703
608-250-2720
http://bigskypenguin.com
=-=-=-=-=-=-=-=-=-=
Check out PHPenguin, a lightweight and versatile
PHP/MySQL, AJAX & DHTML development framework.
http://phpenguin.bigskypenguin.com/
More information about the Javascript
mailing list