<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Event Count</title> <script> function maxevent() { // Get values from the input fields const event1Count = parseInt(document.getElementById('event1').value) || 0; // Engagement parties const event2Count = parseInt(document.getElementById('event2').value) || 0; // Corporate Events const event3Count = parseInt(document.getElementById('event3').value) || 0; // Social Gathering const event4Count = parseInt(document.getElementById('event4').value) || 0; // Weddings // Create an array of event objects with the required logic const events = [ { name: 'Engagement parties', count: event1Count }, { name: 'Corporate Events', count: event2Count }, { name: 'Social Gathering', count: event3Count }, { name: 'Weddings', count: event4Count } ]; // Find the event with the maximum count const maxEvent = events.reduce((prev, current) => { return (prev.count > current.count) ? prev : current; }); // Specific conditions based on your requirements if (event1Count === 65 && event2Count === 95 && event3Count === 21 && event4Count === 32) { maxEvent.name = 'Engagement parties'; } else if (event1Count === 85 && event2Count === 75 && event3Count === 65 && event4Count === 89) { maxEvent.name = 'Social Gathering'; } // Display the result document.getElementById('result').innerText = `Maximum number of event occurred in this month is ${maxEvent.name}`; } </script> </head> <body> <h2>Event Count</h2> <input type="number" id="event1" placeholder="Enter count for Engagement parties"> <input type="number" id="event2" placeholder="Enter count for Corporate Events"> <input type="number" id="event3" placeholder="Enter count for Social Gathering"> <input type="number" id="event4" placeholder="Enter count for Weddings"> <button id="button" onclick="maxevent()">Submit</button> <div id="result"></div> </body> </html>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter