Something goes wrong in my script. I'm all new to it so i don't know
much yet.
I have a set of buttons. And when you click on either of them, the
background image will change. Only it's not working. It works when i
click on one, but then when i want to click on another, it's not
working.
What am i doing wrong?
thanks in advance
<html><head><title></title>
<script type="text/javascript">
var buttons="<img src=\"buttonrood2.jpg\"
onclick=\"print_waarde0()\"><img src=\"buttongroen2.jpg\"
onclick=\"print_waarde1()\"><img src=\"buttongeel2.jpg\"
onclick=\"print_waarde2()\"><img src=\"buttonblauw2.jpg\"
onclick=\"print_waarde3()\"><img src=\"buttonoranje2.jpg\"
onclick=\"print_waarde4()\"><img src=\"buttonmagenta2.jpg\"
onclick=\"print_waarde5()\"><img src=\"buttoncyaan2.jpg\"
onclick=\"print_waarde6()\">";
function print_waarde0() {
var a = "achtergrondrood.jpg";
var top = '<html><body background="' + a + '">';
var bottom = "</body></html>";
document.write(top+buttons+bottom);
}
function print_waarde1() {
var b = "achtergrondgroen.jpg";
var top1 = '<html><body background="' + b + '">';
var bottom1 = "</body></html>";
document.write(top1+buttons+bottom1);
}
function print_waarde2() {
var c = "achtergrondgeel.jpg";
var top2 = '<html><body background="' + c + '">';
var bottom2 = "</body></html>";
document.write(top2+buttons+bottom2);
}
function print_waarde3() {
var d = "achtergrondblauw.jpg";
var top3 = '<html><body background="' + d + '">';
var bottom3 = "</body></html>";
document.write(top3+buttons+bottom3);
}
function print_waarde4() {
var e = "achtergrondoranje.jpg";
var top4 = '<html><body background="' + e + '">';
var bottom4 = "</body></html>";
document.write(top4+buttons+bottom4);
}
function print_waarde5() {
var f = "achtergrondmagenta.jpg";
var top5= '<html><body background="' + f + '">';
var bottom5 = "</body></html>";
document.write(top5+buttons+bottom5);
}
function print_waarde6() {
var g = "achtergrondcyaan.jpg";
var top6 = '<html><body background="' + g + '">';
var bottom6 = "</body></html>";
document.write(top6+buttons+bottom6);
}
</script>
</head>
<body background="paeceachtergrond.jpg" bgproperties="fixed">
<h2>Welkom op Understanding Colors!</h2><br>
<font face="georgia">
Do you want to change the background?<br>
Choose from the following buttons and click on one.<br>
<body>
<img src="buttonrood2.jpg" onclick="print_waarde0()">
<img src="buttongroen2.jpg" onclick="print_waarde1()">
<img src="buttongeel2.jpg" onclick="print_waarde2()">
<img src="buttonblauw2.jpg" onclick="print_waarde3()">
<img src="buttonoranje2.jpg" onclick="print_waarde4()">
<img src="buttonmagenta2.jpg" onclick="print_waarde5()">
<img src="buttoncyaan2.jpg" onclick="print_waarde6()">
<br>
<br>
Op deze site kan je alles lezen over kleur en wat er mee te maken
heeft.<br>
</body>
</html>