cdnhype
02-14-2007, 06:07 AM
Hello Everybody,
This is my first time posting within the DD forum but a long time user of the website. Can I please pick some of your brains with my problem?
Here is my issue:
I've got a CSS class that I need to dynamically change within an onclick function then call a render function. That render call is also done on page load; this will over write it. I'm trying to change the color of the rendered div by modifying the CSS firstly. The onclick event first modifies the css class then calls the render function that will render the div again with the new updated CSS.
Here is the CSS:
<style type='text/css'>
#div1{
padding:7px 2px 2px 4px;background:#F8A0E0;
}
#div1 a, #div1 h2{
color:#666666;
}
</style>
Here are the functions:
<script type="text/javascript">
function setColor(a, b) {
//this how I can change the color of the div .. it is changing the backgroundcolor but its not actually updating the CSS class that the renderDiv function calls
document.getElementById(a).style.backgroundColor = b;
//then i need to call the renderDiv event to render the div with the new CSS background color change.
renderDiv(a);
}
</script>
My div on page:
<div id="div1">Content Here</div>
Call to the setColor function:
<a herf="javascript:setColor('div1', '#333333');">Change Color</a>
This is driving me crazy ... but probably because I'm kind of a JS newbie.
Thanks in advance!
Chris
This is my first time posting within the DD forum but a long time user of the website. Can I please pick some of your brains with my problem?
Here is my issue:
I've got a CSS class that I need to dynamically change within an onclick function then call a render function. That render call is also done on page load; this will over write it. I'm trying to change the color of the rendered div by modifying the CSS firstly. The onclick event first modifies the css class then calls the render function that will render the div again with the new updated CSS.
Here is the CSS:
<style type='text/css'>
#div1{
padding:7px 2px 2px 4px;background:#F8A0E0;
}
#div1 a, #div1 h2{
color:#666666;
}
</style>
Here are the functions:
<script type="text/javascript">
function setColor(a, b) {
//this how I can change the color of the div .. it is changing the backgroundcolor but its not actually updating the CSS class that the renderDiv function calls
document.getElementById(a).style.backgroundColor = b;
//then i need to call the renderDiv event to render the div with the new CSS background color change.
renderDiv(a);
}
</script>
My div on page:
<div id="div1">Content Here</div>
Call to the setColor function:
<a herf="javascript:setColor('div1', '#333333');">Change Color</a>
This is driving me crazy ... but probably because I'm kind of a JS newbie.
Thanks in advance!
Chris