Javascript LEGGERE E SCRIVERE






<!DOCTYPE html>
<html>
<body>

First Name: <input name="fname" type="text" value="Michael" onclick="myFunction2(0)" ><br>
First Name: <input name="fname" type="text" value="Doug" onclick="myFunction2(1)">

<p>Click the button to get the tag name of the first element in the document that has a name attribute with the value "fname".</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
var x = document.getElementsByName("fname")[0].value;
document.getElementById("demo").innerHTML = x;
}

function myFunction2(Valore) {
var x = document.getElementsByName("fname")[Valore].value;
document.getElementById("demo").innerHTML = x;
}





</script>

</body>
</html>










( javascriptleggereescrivere.html )- by Paolo Puglisi - Modifica del 17/12/2023