[thelist] Formatting On The Fly

Warden, Matt mwarden at odyssey-design.com
Thu Mar 8 14:22:21 CST 2001


> Is it possible to apply text formatting on the fly, based on a user's mouse
> click?
> I have a series of radio buttons, and Id like when one is clicked on to set
> some text to red, and when the other is clicked, the same text to black.
>
> Is this JS?  DHTML?  I have the CSS classes in place, but am at a loss about
> how to call them client-side.
> Thanks all.

This should set you on the right track...


<script language="JavaScript">

    function changeColor(p_sColor)
    {
        document.all.mydiv.style.color = p_sColor;
    }

</script>


<div name="mydiv" style="color: red;">Dan says: Speoll Chekor is yer
frend</div>

<a href="javascript:changeColor('blue');">Change to Blue</a>


Now, the which browsers support this is another story... and I'm not gonna
rekindle THAT debate again...



--
mattwarden
mattwarden.com





More information about the thelist mailing list