-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
24 lines (21 loc) · 958 Bytes
/
Copy pathmain.js
File metadata and controls
24 lines (21 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener("DOMContentLoaded", function(event) {
const form = document.getElementById('formulario-contacto');
form.addEventListener('submit', e => {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const subject = document.getElementById('subject').value;
console.log(name, email, subject);
});
let printButton = document.getElementById("print-btn");
printButton.addEventListener("click", function() {
window.print();
let element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(document.body.innerHTML));
element.setAttribute('download', 'filename.pdf');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
});
});