28 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			28 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|   | // contact-form.js
 | ||
|  | 
 | ||
|  | document.addEventListener('DOMContentLoaded', function() { | ||
|  |   const contactForm = document.getElementById('contactForm'); | ||
|  | 
 | ||
|  |   if (contactForm) { | ||
|  |     contactForm.addEventListener('submit', function(event) { | ||
|  |       event.preventDefault(); // Prevent the form from submitting the traditional way
 | ||
|  | 
 | ||
|  |       // Generate a random ticket number
 | ||
|  |       const ticketNumber = Math.floor(Math.random() * 1000000); // Generates a random number between 0 and 999999
 | ||
|  | 
 | ||
|  |       // Retrieve form values
 | ||
|  |       const name = encodeURIComponent(document.getElementById('name').value); | ||
|  |       const email = encodeURIComponent(document.getElementById('email').value); | ||
|  |       const message = encodeURIComponent(document.getElementById('message').value); | ||
|  | 
 | ||
|  |       // Construct the mailto link
 | ||
|  |       const subject = `Support Ticket #${ticketNumber}`; | ||
|  |       const body = `Name: ${name}%0AEmail: ${email}%0AMessage:%0A${message}`; | ||
|  |       const mailtoLink = `mailto:info@photofuel.tech?subject=${subject}&body=${body}`; | ||
|  | 
 | ||
|  |       // Open the default mail client
 | ||
|  |       window.location.href = mailtoLink; | ||
|  |     }); | ||
|  |   } | ||
|  | }); |