This question already has an answer here:
Im creating a really simple random number generator for fun to go with the breeding system in PokeMMO. Using the provided spaces you enter the stats of your parent pokemon and click a button to randomly generate a number between each stat.
For example: User enters in that "Mom" has 25 HP and "Dad" has 13 HP. When the button is clicked I want a random number from 13-25 to be generated in the HP spot under "Baby"
But I really have no idea one how to go about it. I put in ID tags to use document.getElementById but after that how do I generate a random number between them, and then have the result show up under ID tag "_result"?
<html>
<head>
<title>
</title>
</head>
<body>
<center>
<h2>Pokemon Breeder</h2>
<br /><br />
<table style="width: 300px;" border="1" cellspacing="5px" cellpadding="5px">
<tr>
<td colspan="2"> <center>Mom</center> </td>
<td colspan="1"> <center>Baby</center> </td>
<td colspan="2"> <center>Dad</center> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="hp_one"/> </td> <td> HP </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="hp_result"/> </td>
<td> HP </td><td><input type="text" maxlength="2" style="width: 30px;" id="hp_two"/> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="atk_one"/> </td> <td> Atk </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="atk_result"/> </td>
<td> Atk </td><td><input type="text" maxlength="2" style="width: 30px;" id="atk_two"/> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="def_one"/> </td> <td> Def </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="def_result"/> </td>
<td> Def </td><td><input type="text" maxlength="2" style="width: 30px;" id="def_two"/> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="spatk_one"/> </td> <td> Sp Atk </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="spatk_result"/> </td>
<td> Sp Atk </td> <td><input type="text" maxlength="2" style="width: 30px;" id="spatk_two"/> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="spdef_one"/> </td> <td> Sp Def </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="spdef_result"/> </td>
<td> Sp Def </td><td><input type="text" maxlength="2" style="width: 30px;" id="spdef_two"/> </td>
</tr>
<tr>
<td><input type="text" maxlength="2" style="width: 30px;" id="spd_one"/> </td> <td> Spd </td>
<td><input type="text" maxlength="2" style="width: 30px;" id="spd_result"/> </td>
<td> Spd </td><td><input type="text" maxlength="2" style="width: 30px;" id="spd_two"/> </td>
</tr>
</table>
<br /> <button type="button" onclick="rollthedice();">Roll the Dice!!!</button>
</center>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire