Hi everyone,
Please assist with the following, I’m trying to create an eventlistener for two events and this is what I have created, this is for a form.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="test.css">
<title>ALO CheckList</title>
</head>
<body>
<h1>
Security Signoff CheckList
</h1>
<div>
<h2>
Customer Documents
</h2>
<form>
<p>
<div>
<label>
ID
</label>
<input type="checkbox" id="IDcheckbox">
</div>
<div>
<label>
Comments:
</label>
<textarea id="AutoComments" rows="10" cols="60"></textarea>
</div>
<div>
<button>
Done Checking
</button>
</div>
</p>
</form>
</div>
<script src="test.js"></script>
</body>
</html>
javascript code
//what I need to happen
/*
If the check box is not selected per section, comments must be added
comments to be added (document not provided, document older than 3 months)
*/
var checkbox = document.querySelector("IDcheckbox");
checkbox.addEventListener( 'change', function() {
if(this.checked) {
// Checkbox is checked.
} else {
// Checkbox is not checked add comments/auto comments "document not provided" to Comments on
}
});