<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport"…
- User
- Assistant
- User
podrias perfeccionar y colocar los 100 numeros en columnas de 10 en 10 modifica el ccs de ser necesario al igual que el java
- Assistant
podrias perfeccionar y colocar los 100 numeros en columnas de 10 en 10 modifica el ccs de ser necesario al igual que el java
It looks like there are a couple of issues with the HTML code you've provided:
Duplicated <head> and <body> Tags: The document includes duplicate <head> and <body> tags. You should ensure these are opened and closed only once within an HTML file.
Script and Link Loading: Since you're using two different sections of JavaScript code (scripts.js), ensure both functionalities are properly included within the one script file, or separate the functionalities accordingly.
Here's a cleaned-up version of your HTML structure:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Números Vendidos y Generador de Boletas de Rifa</title>
<link rel="stylesheet" href="styles.css">
<!-- Ensure html2canvas is loaded for screen capture functionality -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<!-- Link to your JavaScript functionality -->
<script src="script.js" defer></script>
</head>
<body>
<h1>Números Vendidos</h1>
<table>
<tbody id="number-table">
<!-- Numbers will be generated here with JavaScript -->
</tbody>
</table>
<div class="button-container">
<button onclick="clearData()">Limpiar Datos</button>
<button onclick="saveData()">Guardar Números Vendidos</button>
<button onclick="captureScreen()">Capturar Pantalla</button>
</div>
<div class="container">
<h1>Generador de Boletas de Rifa</h1>
<form id="raffleForm">
<input type="text" id="ticketNumber" placeholder="Número de Ticket" required autocomplete="off">
<input type="text" id="name" placeholder="Nombre del Participante" required autocomplete="off">
<input type="file" id="templateUpload" accept="image/*" required>
<button type="submit">Generar Boleta</button>
</form>
<canvas id="raffleCanvas" style="display:none;"></canvas>
</div>
</body>
</html>
Notes:
script.js file includes the necessary JavaScript logic for both the "Números Vendidos" functionality and the "Generador de Boletas de Rifa".html2canvas library is loaded in the <head> for screen capture functionality. Ensure your script utilizes it correctly.defer attribute in your <script> tags to ensure your JavaScript is executed after the HTML has been parsed. This can prevent errors related to DOM elements not being fully loaded when the scripts run.To generate 100 numbers in a table with 10 columns and 10 rows, you'll need to adjust both your HTML structure and CSS styling. Additionally, you'll need JavaScript to populate the table dynamically. Here's how you can set it up:
Your HTML table structure is already in place, so let's keep it and focus on generating the numbers:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Números Vendidos y Generador de Boletas de Rifa</title>
<link rel="stylesheet" href="styles.css">
<!-- Ensure html2canvas is loaded for screen capture functionality -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<!-- Link to your JavaScript functionality -->
<script src="script.js" defer></script>
</head>
<body>
<h1>Números Vendidos</h1>
<table id="number-table">
<tbody>
<!-- Numbers will be generated here by JavaScript -->
</tbody>
</table>
<div class="button-container">
<button onclick="clearData()">Limpiar Datos</button>
<button onclick="saveData()">Guardar Números Vendidos</button>
<button onclick="captureScreen()">Capturar Pantalla</button>
</div>
<div class="container">
<h1>Generador de Boletas de Rifa</h1>
<form id="raffleForm">
<input type="text" id="ticketNumber" placeholder="Número de Ticket" required autocomplete="off">
<input type="text" id="name" placeholder="Nombre del Participante" required autocomplete="off">
<input type="file" id="templateUpload" accept="image/*" required>
<button type="submit">Generar Boleta</button>
</form>
<canvas id="raffleCanvas" style="display:none;"></canvas>
</div>
</body>
</html>
styles.css)Add these styles to ensure the table looks neat:
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
td {
border: 1px solid #dddddd;
text-align: center;
padding: 8px;
width: 10%;
}
thead {
background-color: #f2f2f2;
}
.button-container {
margin-bottom: 20px;
}
.container {
margin-top: 40px;
}
script.js)Add the following JavaScript to populate the table:
document.addEventListener("DOMContentLoaded", function() {
generateNumbers();
});
function generateNumbers() {
const tableBody = document.getElementById('number-table');
let html = '';
for (let i = 0; i < 10; i++) {
html += '<tr>';
for (let j = 1; j <= 10; j++) {
const number = i * 10 + j;
html += `<td>${number}</td>`;
}
html += '</tr>';
}
tableBody.innerHTML = html;
}
function clearData() {
// Add functionality to clear data
}
function saveData() {
// Add functionality to save data
}
function captureScreen() {
html2canvas(document.body).then((canvas) => {
const link = document.createElement('a');
link.download = 'captura.png';
link.href = canvas.toDataURL();
link.click();
});
}
generateNumbers function dynamically creates table rows and columns, filling them with numbers 1 through 100. This is accomplished through two nested loops.<table> element for numbers is easily filled with the generated numbers through JavaScript.This set-up will give you a page where numbers 1 to 100 are organized in a table with 10 rows and 10 columns, ready to be enhanced or styled as needed.