OK, First post in this area. Yesterday I decided to learn Javascript, so I'm a newbie in this field.
The problem is:
I want to change the color of a piece of text on my page. The color (in hex-value) is generated in a function when a user clicks a radio-button. It works to change the color of the background of my page to that color. I can also set the color of the string-variable (which holds the text that has to be in color) to that color (it works, I tested it). But the problem is that I have to refresh or reload the writing of the string. Can this be done (and how)? (If I refresh the whole page with 'document.reload();' the radio buttons are also reset, so that doesn't work)
These are the things I'm talking about (the important parts of the page):
code:
<html>
<head>
<script language="JavaScript">
tekstje = "Radio buttons:";//this holds the text that should get colored
function setFontKleur()
{
var kleur="#";
if(document.form_2.radio_red.checked){
kleur += "FF";
}else{
kleur += "00";
}
if(document.form_2.radio_green.checked){
kleur += "FF";
}else{
kleur += "00";
}
if(document.form_2.radio_blue.checked){
kleur += "FF";
}else{
kleur += "00";
}
//this works, if you write 'tekstje' now, it will be the right color (done that)
tekstje = tekstje.fontcolor(kleur);
//the next thing also works, as you can see in the link below (i hope)
document.bgColor=kleur;
}
</script>
</head>
<body bgcolor=#B6B6B6>
<form name="form_2">
<script language="JavaScript">
//THE NEXT THING SHOULD BE REFRESHED (tekstje) when a radio-button is clicked
document.write(tekstje);
</script>
<input type="radio" name="radio_red" onClick="redClicked();">Red
//function redClicked() then calls setFontKleur()
<input type="radio" name="radio_blue" onClick="blueClicked();">Blue
<input type="radio" name="radio_green" onClick="greenClicked();">Green
</form>
</body>
</html>
And this is the page.
PS: Sorry for the mixture of Dutch and bad English in my code.
PSII: Use the code of my link (right-click, view source), not the code that you see here. There are some functions missing.
Edit: damn UBB
[This message has been edited by eighdee (edited 08-23-2002).]