Get the name of a week field:
var x = document.getElementById("myWeek").name;
Click the button to return the value of the name attribute of the week field.
input elements with type="week" are not supported in Internet Explorer or Firefox.
<!DOCTYPE html> <html> <body> Year and Week: <input type="week" id="myWeek" name="year_week"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w . j ava 2s . c om var x = document.getElementById("myWeek").name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The name property sets or gets the value of the name attribute of a week field.
The name attribute will identify form data after it submitting to the server.
Only form elements with a name attribute will be passed to the server.
The <input type="week"> element is not supported in Firefox.
Value | Description |
---|---|
name | Specifies the name of the week field |
The name property returns a String representing the name of the week field.