Input Week value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Week

Description

The value property sets or gets the value attribute of a week field.

Set the value property with the following Values

ValueDescription
YYYY-WWW Sets the week and year.

Explanation of components:

  • YYYY - year (e.g. 2011)
  • The literal string "-W" indicates "week"
  • WW - week (in the range of 1 to 52 or 53 )

Example: 2018-W15

Return Value

A String, representing the year and week of the week field

The following code shows how to Set the week and year for a week field:

Demo Code

ResultView the demo in separate window

<!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 .  java  2  s  .c  o m
    document.getElementById("myWeek").value = '2000-W33';
    document.getElementById("demo").innerHTML = 'changed';
}
</script>

</body>
</html>

Related Tutorials