I am wondering why in the following script comment 1 and comment 2 dosent work I know that we can access directly element by id without passing by "form" however am asking the question for educational purpose Thank you
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script>
function ulDisply()
{
//var element = document.myform.getElementsByName("name1")[0].value;//1
//var element = document.myform.getElementsById("id1").value;//2
//var element = document.myform.elements[0].value;//3
var element = document.myform.d.value;//4
document.write("you number is "+ element +"<br>");
}
</script>
</head>
<body>
<form name="myform">
<input type="number" name="n" id="d">
<input type="submit" onclick="ulDisply()">
</form>
</body>
</html>