Temat: getElementById - przykłady
<script>
function fun(x)
{
var b=document.getElementById('b'+x);
b.value=(b.value*2);
}
function czysc()
{
for (i=0; i<10; i++)
{
var b=document.getElementById('b'+i);
b.value=i;
}
}
</script>
<form>
<input type="button" value="0" id="b0" onclick="fun(0)">
<input type="button" value="1" id="b1" onclick="fun(1)">
<input type="button" value="2" id="b2" onclick="fun(2)">
<input type="button" value="3" id="b3" onclick="fun(3)">
<input type="button" value="4" id="b4" onclick="fun(4)">
<input type="button" value="5" id="b5" onclick="fun(5)">
<input type="button" value="6" id="b6" onclick="fun(6)">
<input type="button" value="7" id="b7" onclick="fun(7)">
<input type="button" value="8" id="b8" onclick="fun(8)">
<input type="button" value="9" id="b9" onclick="fun(9)"><br>
<input type="button" value="czysc" onclick="czysc()">
</form>