Suppose we have a textbox in html and we want to know the value of the textbox then
in javascript we can get the element by two ways:
1. document.getElementById
2. document.getElementsByName
1. document.getElementById
2. document.getElementsByName
<input type="text" id="txtName" name="txtName" value="Mathew" />
function getName() {
var Name = document.getElementById("txtName").value;
var Name1 = document.getElementsByName("txtName").value;
alert(Name);
//alert(Name1);
}
It will display value in textbox by using “.value” attribute.
nice work sir.
ReplyDelete