Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="es">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Programacion Estatica</title>
- <link href="estilo.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="header">
- <h1>JavaScript</h1>
- </div>
- <div id="secondaryContent"></div>
- <div id="content">
- <p>
- <strong>a-</strong> Crear la función:<br /> <strong>agregarEvento(X)</strong><br />
- Esta función debe agregar al div de id="eventosOcurridos" la hora
- actual concatenada con el string X que ingresa como parametro y luego
- una línea horizontal para ir separando los eventos. <i>(Ayuda:
- Recuerde usar los métodos getHours() y getMinutes() de un objeto
- Date)</i>
- </p>
- <p>
- <strong>b-</strong>Al hacer clic sobre el botón Comienzo:
- </p>
- <ul>
- <li>Agregar el comentario "Comenzo el partido" en el div
- utilizando la función creada en el punto anterior.</li>
- </ul>
- <p>
- <strong>c-</strong> Al hacer clic sobre los botones Gol llamar a
- funciones que deben hacer las siguientes acciones:
- </p>
- <ul>
- <li>Sumar en uno el input de id="golesEquipo1" o
- id="golesEquipo2" según corresponda.</li>
- <li>Agregar el comentario "Gol Equipo " concatenado con el valor
- del input de id="equipo1" o id="equipo2" según corresponda. Utilizar
- la funcion creada en el punto (a).</li>
- </ul>
- <p>
- <strong>d-</strong> Al hacer clic sobre el botón final llamar a una
- función <b>final()</b> que deben agregar el comentario "Gano el
- equipo " concatenado con el nombre del equipo Ganador " concatenado
- con el número de goles de diferencia. En caso de empate agregar el
- mensaje "Partido empatado". Utilizar la funcion creada en el punto
- (a).<br /> Ej. Blanco 5 Goles, Negro 3 Goles. Mensaje= "Gano el
- equipo Blanco por 2 Goles.
- </p>
- <hr />
- <form action="#">
- <fieldset>
- <legend>Acciones</legend>
- <input value="Comienzo" type="button" onclick="agregarEvento('Comenzo el partido');" /> <input value="Final" type="button" onclick="final();" />
- </fieldset>
- <hr />
- <fieldset>
- <legend> Equipo 1</legend>
- <input value="Blanco" type="text" id="equipo1" /> <input value="0"
- type="text" id="golesEquipo1" size="3" readonly="readonly" /> <input
- value="Gol" type="button" onclick="sumarGol('equipo1');" />
- <hr />
- </fieldset>
- <fieldset>
- <legend>Equipo 2</legend>
- <input value="Negro" type="text" id="equipo2" /> <input value="0"
- type="text" id="golesEquipo2" size="3" readonly="readonly" /> <input
- value="Gol" type="button" onclick="sumarGol('equipo2');" />
- </fieldset>
- </form>
- <fieldset>
- <legend>Eventos Ocurridos</legend>
- <div id="eventosOcurridos"></div>
- </fieldset>
- <br />
- <br />
- <div id="footer">
- <p>
- Copyright © 2006 Sitename.com. Designed by <a href="#">Free
- CSS Templates</a>
- </p>
- </div>
- </div>
- <script type="text/javascript">
- function agregarEvento(x){
- var tiempo = new Date(); // Creo el objeto del tiempo
- var hora = tiempo.getHours(); // Obtengo la hora
- var minuto= tiempo.getMinutes(); // obtengo los minutos
- // el getElementById es donde voy a escribir... y escribo el mensaje que me pasan en X mas la hora y los minutos y una linea
- var msj = " " + hora +":"+ minuto +" -->"+ x + "<br> ------------------------------------";
- document.getElementById("eventosOcurridos").innerHTML = document.getElementById("eventosOcurridos").innerHTML + msj + "<br>";
- };
- function sumarGol(equipo){
- var gol1;
- var gol2;
- if (equipo == 'equipo1'){
- //alert(document.getElementById("golesEquipo1").value);
- gol1 = parseInt(document.getElementById("golesEquipo1").value) + 1;
- //alert(gol1);
- document.getElementById("golesEquipo1").value=gol1;
- agregarEvento('Gol de Equipo 1 -->' + gol1);
- }else if (equipo== 'equipo2'){
- gol2 = parseInt(document.getElementById("golesEquipo2").value) + 1;
- document.getElementById("golesEquipo2").value=gol2;
- agregarEvento('Gol de Equipo 2 -->' + gol2);
- };
- };
- function final(){
- var gol1;
- var gol2;
- gol1 = document.getElementById("golesEquipo1").value;
- gol2 = document.getElementById("golesEquipo2").value;
- if (gol1==gol2){
- agregarEvento('Empate');
- } else if(gol1 > gol2){
- agregarEvento('Gano Equipo 1 con '+ gol1 + ' Goles');
- } else {
- agregarEvento('Gano Equipo 2 con ' + gol2 + ' Goles');
- };
- };
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement