tags:

views:

37

answers:

2

Hi folks,

I am a javascript beginner . I am working on a wordsmith game that display's a clue (on the roll of a dice ) to a word . now i need to display the blank spaces of the word and a clue below it . I am not knowing hot to display the content to the place i want in the page ???

<html>
<head>
<script type="text/javascript">
form1= document.forms[0];
function display()
{
 words=new Array("Elephant","Tiger","Panther","Giraffe","Zebra","Anaconda");
 phrases=new Array("Largest Land Mammal","Striped Animal moving towards  Extinction","Found in the Amazon Jungle","Found in Africa","It helps us Cross","Very  Dangerous Reptile");

 count = words[i].length;
 while(count>0)
 {
 document.write("__")//to display the word with blank spaces
 document.write(""); // space in between characters
 count--;
 }
}
 function show_dice()
 {
 randomnumber=Math.floor(Math.random()*6);
 i=randomnumber;
 randomnumber = randomnumber + 1;
 document.getElementById("myButton1").value=randomnumber;
 document.getElementById("myButton1").disabled="disabled";
 }
 </script>
<link rel="stylesheet" type="text/css" href="keyboard.css">
</head>
<body>
<form>
<input type="button" id = "myButton1" name ="Button1" onclick="show_dice()"        value="Click the Dice!!!">
 <h1>Enter Your Guess For the Word Below</h1>
 <h2> Clue to the Word is :</h2>
 <input type="text" value="" class="keyboardInput">
 </form>
 </body>
 </html>
+1  A: 

Just for start, you could to create a <input type=text id=clue /> and to edit it's content by running

document.getElementById("clue").value= "___";

Later, you can to create a <div> and alter it's content through .innerHTML property;

Rubens Farias
A: 

Instead of answering your question I'll recommend reading W3C DOM -Introduction on quirksmode.org. It explains the "why" of Rubens' answer and gives you knowledge to solve similar problems in the future.

Nickolay