1

Temat: [JS] form

<script>
    function bobr()
    {
        var t=document.getElementById("t"); // uchwyt do id=t
        var w=document.getElementById("w"); // uchwyt do id=w
        w.innerHTML=t.value; // wyswietlene w id=w wartości z id=t
    }
</script>

<form style="font-size: 32px; margin: 100px;">
    text(t): <input type="text" id="t" value="1"><br>
    number(n): <input type="number" id="n" value="1"><br>
    <input type="checkbox" id="c"> checkbox(c)<br>
    <input type="radio" name="r" id="r1"> radio 1(r1)
    <input type="radio" name="r" id="r2"> radio 2(r2)
    <input type="radio" name="r" id="r3"> radio 3(r3)
    <input type="radio" name="r" id="r4"> radio 4(r4)
    <br>
    <input type="button" value="OK" onclick="bobr()">
</form>
<hr>
<span id="w" style="font-size: 32px; margin: 100px;"></span>

2

Odp: [JS] form

<script>
    function bobr()
    {
        var t=document.getElementById("t"); // uchwyt do id=t
        var w=document.getElementById("w"); // uchwyt do id=w
        w.innerHTML=t.value; // wyswietlene w id=w wartości z id=t
        var n=document.getElementById("n");
        w.innerHTML=n.value;
        var c=document.getElementById("c");
        if(c.checked) w.innerHTML="tak"; else w.innerHTML="nie";
        var r1=document.getElementById("r1");
        if (r1.checked) w.innerHTML="r1";
        var r2=document.getElementById("r2");
        if (r2.checked) w.innerHTML="r2";
        var r3=document.getElementById("r3");
        if (r3.checked) w.innerHTML="r3";
        var r4=document.getElementById("r4");
        if (r4.checked) w.innerHTML="r4";
    }
</script>

<form style="font-size: 32px; margin: 100px;">
    text(t): <input type="text" id="t" value="1"><br>
    number(n): <input type="number" id="n" value="1"><br>
    <input type="checkbox" id="c"> checkbox(c)<br>
    <input type="radio" name="r" id="r1"> radio 1(r1)
    <input type="radio" name="r" id="r2"> radio 2(r2)
    <input type="radio" name="r" id="r3"> radio 3(r3)
    <input type="radio" name="r" id="r4"> radio 4(r4)
    <br>
    <input type="button" value="OK" onclick="bobr()">
</form>
<hr>
<span id="w" style="font-size: 32px; margin: 100px;"></span>