The value
attribute from the input week element
specifies a week and year for the week field.
The value
property sets or gets value attribute of a week field.
value |
Yes | No | No | Yes | Yes |
Return the value property.
var v = weekObject.value
Set the value property.
weekObject.value=YYYY-WWW
Value | Description |
---|---|
YYYY-WWW | Specifies the week and year.
|
A String type value representing the year and week of the week field.
The following code shows how to get the week and year of a week field.
<!DOCTYPE html>
<html>
<body>
<input type="week" id="myWeek" value="1995-W35">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w . ja va2 s .c o m-->
var x = document.getElementById("myWeek").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to set the week and year for a week field.
<!DOCTYPE html>
<html>
<body>
Week and Year: <input type="week" id="myWeek">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w . j a v a2s. co m-->
document.getElementById("myWeek").value = "2014-W48";
}
</script>
</body>
</html>
The code above is rendered as follows: