Temat: getElementById: innerHTML i value
<script>
function a1()
{
var a = document.getElementById("a");
a.innerHTML = parseInt(a.innerHTML)+1;
}
function a2()
{
var a = document.getElementById("a");
a.innerHTML = parseInt(a.innerHTML)-1;
}
function a3()
{
var a = document.getElementById("a");
a.innerHTML = parseInt(a.innerHTML)+5;
}
function a4()
{
var a = document.getElementById("a");
a.innerHTML = parseInt(a.innerHTML)*parseInt(a.innerHTML);
}
function a5()
{
var a = document.getElementById("a");
a.innerHTML = Math.sqrt(parseInt(a.innerHTML));
}
function f1()
{
var a = document.getElementById("a");
var b = document.getElementById("textbox");
a.innerHTML = b.value;
}
</script>
<button onclick="a1()">dodaj +1</button>
<button onclick="a2()">dodaj -1</button>
<button onclick="a3()">dodaj +5</button><br>
<button onclick="a4()">potega</button>
<button onclick="a5()">pierwiastek</button>
<hr>
<form>
<input type="text" id="textbox">
<input type="button" value="OK" onclick="f1()">
</form>
<hr>
<span id="a">0<span>