html random picker
- User
html random picker
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
html random picker
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Creating a random picker using HTML, CSS, and JavaScript can be a fun project. Below is a simple example of how you can make a random picker that randomly selects an item from a predefined list when a button is clicked:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Picker</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Random Picker</h1>
<ul id="itemList">
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
<li>Date</li>
<li>Elderberry</li>
</ul>
<button id="pickButton">Pick a Random Item</button>
<h2 id="result"></h2>
</div>
<script src="script.js"></script>
</body>
</html>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
padding: 10px 15px;
font-size: 16px;
cursor: pointer;
}
h2 {
margin-top: 20px;
color: #333;
}
document.getElementById('pickButton').addEventListener('click', function() {
const items = document.querySelectorAll('#itemList li');
const randomIndex = Math.floor(Math.random() * items.length);
const randomItem = items[randomIndex].textContent;
document.getElementById('result').textContent = `You picked: ${randomItem}`;
});
HTML: We have a simple list of items within an unordered list (<ul>). A button is provided for the user to initiate the random selection. The result will be displayed in an <h2> element.
CSS: Basic styling is added to center the content and make it look clean and presentable.
JavaScript: We add an event listener to the button. When the button is clicked, we generate a random index based on the number of items in the list, retrieve the corresponding item, and display it in the result area.
To see this in action, you can create three separate files on your local machine: index.html, styles.css, and script.js. Copy the corresponding code into each file. Then open index.html in a web browser.
Feel free to modify the list or styles as per your liking!
Not yet included in a published release.