HTML DOM Input Week stepDown( ) Method


The HTML DOM Input Week stepDown() method defines the amount of weeks the week field should decrease.

Syntax

Following is the syntax −

Calling stepDown() method with a number, which by default is equal to 1

inputWeekObject.stepDown(number)

Example

Let us see an example for Input Week stepDown() method −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Week stepDown()</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form>
<fieldset>
<legend>Week-stepDown( )</legend>
<label for="WeekSelect">Week and Year :
<input type="week" id="WeekSelect" value="2055-W04">
</label>
<input type="button" onclick="changeStep('2')" value="Decrease Weeks by 2">
<input type="button" onclick="changeStep('3')" value="Decrease Weeks by 3">
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   function changeStep(myStep) {
      inputWeek.stepDown(myStep);
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking any button −

Clicking ‘Decrease Weeks by 2’ button −

Clicking ‘Decrease Weeks by 3’ button −

Updated on: 30-Jul-2019

49 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements