1//Html
2<form id="myForm" name="myForm">
3 <input id="email" name="email" value="some@email.com" />
4</form>
5
6//JS
7var x=document.forms["myForm"]["email"].value;
1//HTML
2<input type="text" name="name" id="uniqueID" value="value" />
3
4//JS
5var nameValue = document.getElementById("uniqueID").value;
6
1// having form like this
2
3<form>
4 <div>
5 <label for="number">Give me number</label>
6 <input type="number" id="number">
7 </div>
8 <div>
9 <button class="btn">Click</button>
10 </div>
11</form>
12
13// this is how u get a value (number)
14document.querySelector("form").addEventListener("submit", get_number);
15function get_number(e){
16 const n = document.getElementById("number").value;
17 console.log('n:', n)
18 e.preventDefault();
19}
20