hi
I read your tutorial about "Change style sheet" at here:
http://www.quirksmode.org/dom/changess.html
I have a problem. I will be happy if you could help me solve this problem.
I created a function to change "style" with javascript dynamically that it is
same as below:
function set_style (element_id, style_name, style_value)
{
document.getElementById(element_id).style.style_name = style_value;
}
there is a problem that this function didn't work.
problem is how i must use a variable in middle of a code syntax?
for more description.
i can use this code in my html body like line below:
<a href="#" onclick="set_style ('test', 'borderColor', 'Red')">change color</a>
but when this code line executed function could not set 'borderColor' in middle
of line in true place.
in ActionScript (for flash), when you want to use a variable in middle of
syntax, you must use "[" , "]" and last dot must be removed from syntax.
for example this to event are same as together in flash actionscript:
this:
on (release) {
mymovie.test.gotoAndPlay(10);
}
and this:
on (release) {
var element_name = "test";
mymovie[element_name].gotoAndPlay(10);
}
and i don't know how i must use same as "actionscript" in "javascript".
I will be so so happy if you can help me solve this problem.
i copy simple example of html code bellow could help for test :) .
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Test Fumction</title>
<script>
function set_style (element_id, style_name, style_value)
{
//document.getElementById(element_id).style.borderColor = style_value;
document.getElementById(element_id).style.style_name = style_value;
}
</script>
</head>
<body>
<a href="#" onclick="set_style ('test', 'borderColor', 'Red')">change color</a>
<div id="test" style="border: 10px solid aqua;">hi. this is a test</div>
</body>
</html>
thank you
Reza Amya
______________________________________________________________________
css-discuss [[email protected]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/