I'll throw it out here on the off chance there's a Java wizard handy. So, I finally quit putting off learning Javascript, and I'm starting out with a simple button-click dice-roller. It displays two random die icons whenever the button is clicked. Here's the code, presented in a stand-alone webpage for clarity's sake:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Roll the Dice</title>
</head>
<body>
<script language="JavaScript">
<!--
function get_random()
{
var ranNum= Math.round((Math.random()*5)+1);
if(ranNum==1)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_one.png";}
if(ranNum==2)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_two.png";}
if(ranNum==3)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_three.png";}
if(ranNum==4)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_four.png";}
if(ranNum==5)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_five.png";}
if(ranNum==6)
{value1.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_six.png";}
var ranNum= Math.round((Math.random()*5)+1);
if(ranNum==1)
{value2.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_one.png";}
if(ranNum==2)
{value2.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_two.png";}
if(ranNum==3)
{value2.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_three.png";}
if(ranNum==4)
{value2.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_four.png";}
if(ranNum==5)
{value2.src="http://photos1.blogger.com/blogger/1875/341/1600/dice_five.png";}
if(ranNum==6)
{value2.src="./dice_six.png";}
}
//-->
</script>
<form name="form1"> <img src="http://photos1.blogger.com/blogger/1875/341/1600/dice_three.png" name="value1"
border="0" height="48" width="48"> <img src="http://photos1.blogger.com/blogger/1875/341/1600/dice_four.png"
name="value2" border="0" height="48" width="48">
<p><input value="Roll the dice." onclick="get_random()" type="button"></p>
<br>
<br>
</form>
</body>
</html>
Now, I try this from my desktop in Firefox, Mozilla, and Konqueror and it works. I paste the script.../script block inside the head tag and the form.../form block into the body. I check it in Blogger preview and it works. Then I save it and try it in my blog proper, and the dice and button show and I can click it, but it doesn't change the dice. Also tried it all in the body the way I show it here. Still no luck. Any idea why?
Here's the dice icons, by the way, if anybody wants them.
PS Javascript's kinda fun! I'm doing this as a proof-of-concept before I hopefully code some fun little toys to spice up my blog with.