What is the difference between a HTML elements id attribute
What is the difference between a HTML element’s id attribute and name attribute?
Solution
The form input element id has nothing to do with the data contained within the element. Input element ids are for hooking the element with JavaScript and CSS. The name attribute is used in the HTTP request sent by your browser to the server as a variable name associated with the data contained in the value attribute.
In other words, By using id attribute we can validate and manipulate the value of an element at client side. By using name attribut, we can validate and manipulate the value of an element at server side.
In java script, by using id attribute we can get the value of input element.
document.getElementById(\"id\").value;
In server side, by using name attribute we can get the value of input element.
request.getParameter(\"name\");
