so i have the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> THISISATITLE </TITLE>
<SCRIPT TYPE="text/javascript">
function afunc(){
var a=document.getElementById("input1").value; var a=parseInt(a); window.a=a;
if(isNaN(a)){alert('Please enter a number');}
else if(a<0){alert('Please enter a number greater than 0');}
else{
var b=document.getElementById("input2").value; var b=parseInt(b); window.b=b; alert('lol');
}
}
</SCRIPT>
<input id="button1" type="button" value="Calculate" onclick="afunc();">
<p> </p>
<input id="input1" type="number" value="1"
<p> First Unit Attack </p>
<input id="input2" type="number" value="1"
<p> First Unit Defense </p>
<input id="input3" type="number" value="1"
<p> First Unit Speed </p>
<input id="input4" type="number" value="1"
<p> Second Unit Attack </p>
<input id="input5" type="number" value="1"
<p> Second Unit Defense </p>
<input id="input6" type="number" value="1"
<p> Second Unit Speed </p>
<p> words here </p>
<p id="input1"></p>
</HEAD>
<BODY>
THISISABODY
</BODY>
</HTML>
and i would like to have it so that when clicking the button and running afunc that variable a shows up at the end of the html but doesn't clear the rest of the text. i looked here:
http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm
and tried to do something similar but it doesn't show up at all. if i do document.write or document.writeln it clears the rest of the page...
Aucun commentaire:
Enregistrer un commentaire