Get Week Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Week

Introduction

The Input object represents an HTML <input> element with type="week".

You can access an <input> element with type="week" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="week" id="myWeek" value="2014-W15">

<button onclick="myFunction()">get the week and year of the week field</button>

<p id="demo"></p>

<script>
function myFunction() {/*w ww  . j  av  a 2  s  .  c  o  m*/
    var x = document.getElementById("myWeek").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials