Calculator Tools Calculator Tools
Create

Lottery Odds Calculator

Sep 26, 2023

About this app

Calculate the odds of winning the lottery based on the number of tickets sold and a lightning strike.

Lottery Odds Calculator Lottery Odds Calculator Number of Tickets Sold: Lightning Strike Odds: Calculate Odds

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Lottery Odds Calculator</title>
<meta name="description" content="Calculate the odds of winning the lottery based on the number of tickets sold and a lightning strike.">
<meta name="keywords" content="lottery, odds, winning, tickets, lightning strike">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
document.addEventListener("DOMContentLoaded", function() {
// Get the form element
var form = document.getElementById("lottery-odds-form");

// Add event listener to the form submit event
form.addEventListener("submit", function(event) {
event.preventDefault(); // Prevent the form from submitting

// Get the values from the input fields
var ticketsSold = parseInt(document.getElementById("tickets-sold").value);
var lightningStrike = parseInt(document.getElementById("lightning-strike").value);

// Calculate the odds of winning the lottery
var odds = 1 / (ticketsSold * lightningStrike);

// Display the odds on the page
var oddsContainer = document.getElementById("odds-container");
oddsContainer.innerHTML = "The odds of winning the lottery are approximately 1 in " + odds.toLocaleString() + ".";
});
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
body {
background-color: #f5f5f5;
font-family: 'Open Sans', sans-serif;
color: #333;
margin: 0;
padding: 0;
}

.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}

.title {
text-align: center;
font-size: 24px;
font-weight: bold;
margin-bottom: 30px;
}

.form-group {
margin-bottom: 20px;
}

.form-label {
display: block;
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}

.form-input {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}

.form-button {
width: 100%;
padding: 10px;
font-size: 16px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
cursor: pointer;
}

.result {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
text-align: center;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1 class="title">Lottery Odds Calculator</h1>

<form id="lottery-odds-form">
<div class="form-group">
<label for="tickets-sold" class="form-label">Number of Tickets Sold:</label>
<input type="number" id="tickets-sold" class="form-input" required>
</div>

<div class="form-group">
<label for="lightning-strike" class="form-label">Lightning Strike Odds:</label>
<input type="number" id="lightning-strike" class="form-input" required>
</div>

<button type="submit" class="form-button">Calculate Odds</button>
</form>

<div id="odds-container" class="result"></div>
</div>
</body>
</html>