Syntax error HTML DOM Input Week form Property

HTML DOM Input Week form Property



The HTML DOM Input Week form property returns the reference of enclosing form for input Week.

Syntax

Following is the syntax −

Returning reference to the form object

inputWeekObject.form

Example

Let us see an example for Input Week form property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Week form</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 id="Mid-Term">
<fieldset>
<legend>Week-form</legend>
<label for="WeekSelect">Examination Week:
<input type="week" id="WeekSelect" value="2019-W36">
</label>
<input type="button" onclick="showExamination()" value="What exams are in this week? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   function showExamination() {
      divDisplay.textContent = 'Examinations: '+inputWeek.form.id;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘What exams are in this week?’ button −

After checking ‘What exams are in this week?’ button −

Updated on: 2019-07-30T22:30:26+05:30

122 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements