Articles directory - Debt Consolidation - Find jobs - Anime Downloads - Internet Advertising

PDA

View Full Version : The output of a text field?


Fry_watson
Feb 13th 2007, 3:10 pm
Ive been making a online turn based game in my free time, and i was wondering how to make it show up that ive bought the weapon. after i click submit its suppose to say you have 1 weapons. But its not working and how can i tell it were i want it to display it at.
heres my code.
sorry if i explained that bad.


<html>
<body background="http://www.script-design.com/img/home0/2.jpg">
<script type="text/javascript">
function Buy()
{
var name=prompt("weapon?","1")
if (name!=null && name!="")

{
document.write("You have" + name + "Weapons")
}
}
</script>
<input type="text" name="prompt" value="1">
<input type="submit" name="prompt" value="Submit">
</body
</html>

lbalance
Feb 13th 2007, 3:19 pm
you need to add <form> tags and tell it to access that function you made onSubmit

giraph
Feb 13th 2007, 3:39 pm
you'll want to use

<input type="button" onclick="Buy();" />

As far as getting it to show up where you want, I suggest making an empty tag like.

<span id="myID"></span>[code]

Then instead of document.write use

[code]document.getElementById("myID").innerHTML = "Your text goes here";