Sie sind auf Seite 1von 11

<head

>
<title>Date</title>
<meta charset="UTF-8">
</head>
<body>
<h1 id="h1"></h1>
<p id="nombre">Victor Manuel Fajardo Hernández</p>
<h2 id="h2">La fecha y la hora son:</h2>
<div id="fecha"></div>
<div id="ejercicio"></div>
<script type="text/javascript">
var fecha = new Date();
var msj;
if (fecha.getHours() < 7) { msj = "Buenas noches";}
else if (fecha.getHours() < 12) { msj = "Buenos días";}
else if (fecha.getHours() < 21) { msj = "Buenas tardes";}
else { msj = "Buenas noches";}
document.getElementById("h1").innerHTML = msj;
document.getElementById("fecha").innerHTML = fecha;
/*Mi ejercicio*/
var divicion=document.getElementById("ejercicio");
var h2=document.getElementById("h2");
var h1=document.getElementById("h1");
divicion.innerHTML = "a) Contenido de innerHTML de elemento identificado
por id=h2: ("+h2.innerHTML+")<br>"+"b) Contenido de outerHTML de
elemento identificado por id=h1: ("+h1.outerHTML+")<br>c) Contenido de de
la propiedad global: location.href: ("+document.location.href+")<br>d)
Contenido de de la propiedad global: location: ("+document.location+")<br>e)
Contenido de de las propiedades globales: screen.width y screen.heigth: (Width
= "+screen.width+", Heigth = "+screen.width+")";
</script>
</body>
</html>
</body>
</html>
<!DOCTYPE
html><html>
<head>
<title>Tarea 3</title>
<meta charset="UTF-8">
</head>
<body>
<h1 id="h1"></h1>
<h1>JOSE VICENTE PEREZ</h1>
<h2 id="h2">La fecha y la hora son:</h2>
<div id="fecha"></div>
<p>
<div><h3>Apartado a):<h3><h3 style="color:blue"
id="contenido_a"></h3></div>
<p>
<div><h3>Apartado b):<h3><h3 style="color:blue"
id="contenido_b"></h3></div>
<p>
<div><h3>Apartado c):<h3><h3 style="color:blue"
id="contenido_c"></h3></div>
<p>
<div><h3>Apartado d):<h3><h3 style="color:blue"
id="contenido_d"></h3></div>
<p>
<div><h3>Apartado e):<h3><h3 style="color:blue"
id="contenido_e"></div>
<script type="text/javascript">
var fecha = new Date();
var msj;
if (fecha.getHours() < 7) { msj = "Buenas noches";}
else if (fecha.getHours() < 12) { msj = "Buenos días";}
else if (fecha.getHours() < 21) { msj = "Buenas tardes";}
else { msj = "Buenas noches";}
document.getElementById("h1").innerHTML = msj;
document.getElementById("fecha").innerHTML = fecha;
document.getElementById("contenido_a").innerHTML =
document.getElementById("h2").innerHTML;
document.getElementById("contenido_b").innerHTML =
document.getElementById("h1").innerHTML;
document.getElementById("contenido_c").innerHTML =
location.href;
document.getElementById("contenido_d").innerHTML =
location.host;
document.getElementById("contenido_e").innerHTML = "Screen
Width: "+ screen.width+" Screen Heigth: "+screen.height;
</script>
</body>
</html>

<!DOCTYPE
html><html>
<head>
<title>HORA</title>
<meta charset="UTF-8">
</head>
<body>
<h1 id="h1"></h1>
<h3>JOSE QUEREIGUA</h3>
<h2 id="h2">La fecha y la hora son:</h2>
<button
onclick="document.getElementById('hora').innerHTML=Date()">¿Que
hora es?</button>
<p id="hora"></p>
<div>
</div>
<script type="text/javascript">
var msj;
if (fecha.getHours() < 7) { msj = "Buenas noches";}
else if (fecha.getHours() < 12) { msj = "Buenos días";}
else if (fecha.getHours() < 21) { msj = "Buenas tardes";}
else { msj = "Buenas noches";}
document.getElementById("h1").innerHTML = msj;
</script>
</body>
</html>
Calculadora

<html>
<head>
<title>Calculadora HTML</title>
</head>

<body bgcolor= "# 000000" text= "gold">


<form name="calculator" >
<input type="button" value="1"
onClick="document.calculator.ans.value+='1'">
<input type="button" value="2"
onClick="document.calculator.ans.value+='2'">
<input type="button" value="3"
onClick="document.calculator.ans.value+='3'">
<input type="button" value="+"
onClick="document.calculator.ans.value+='+'">
<input type="button" value="4"
onClick="document.calculator.ans.value+='4'">
<input type="button" value="5"
onClick="document.calculator.ans.value+='5'">
<input type="button" value="6"
onClick="document.calculator.ans.value+='6'">
<input type="button" value="-"
onClick="document.calculator.ans.value+='-'">
<input type="button" value="7"
onClick="document.calculator.ans.value+='7'">
<input type="button" value="8"
onClick="document.calculator.ans.value+='8'">
<input type="button" value="9"
onClick="document.calculator.ans.value+='9'">
<input type="button" value="*"
onClick="document.calculator.ans.value+='*'">
<input type="button" value="/"
onClick="document.calculator.ans.value+='/'">
<input type="button" value="0"
onClick="document.calculator.ans.value+='0'">
<input type="reset" value="Reset"><input type="button"
value="="
onClick="document.calculator.ans.value=eval(document.calcul
ator.ans.value)">El resultado es
<input type="textfield" name="ans" value="">
</form>
</body>
</html>
Operaciones matemáticas con una variable

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<!-- The style.css file allows you to change the look of your web pages.
If you include the next line in all your web pages, they will all share the same look.
This makes it easier to make new pages for your site. -->
<link href="/style.css" rel="stylesheet" type="text/css" media="all">

<title>Mini calculadora en JavaScript</title>

<script>
function calcula(operacion){
var operando1 = document.calc.operando1.value;
var operando2 = document.calc.operando2.value;
var result = 0;
if (operacion=='+' || operacion=='-' || operacion=='*' || operacion=='/' ) {
result = eval(operando1 + operacion + operando2);
}
if (operacion=='^'){
result = operando1 * operando1;
}
if (operacion=='I'){
result = eval(1 / operando1);
}
if (operacion=='R'){
result = eval(Math .sqrt(operando1));
}
if (operacion=='F'){
result = eval(Math.floor(operando1));
}
if (operacion=='E'){
result = eval(Math.pow(operando1 , operando2));
}

document.calc.resultado.value = result;
}
</script>

</head>
<body>

<form name="calc">
<input type="Text" name="operando1" value="0" size="12">
<br>
<input type="Text" name="operando2" value="0" size="12">
<br>
<input type="Button" name="" value=" + " onclick="calcula('+')">
<input type="Button" name="" value=" - " onclick="calcula('-')">
<input type="Button" name="" value=" X " onclick="calcula('*')">
<input type="Button" name="" value=" / " onclick="calcula('/')">
<input type="Button" name="" value=" x^2 " onclick="calcula('^')">
<input type="Button" name="" value=" 1/x " onclick="calcula('I')">
<input type="Button" name="" value=" sqrt(x) " onclick="calcula('R')">
<input type="Button" name="" value=" Math.floor " onclick="calcula('F')">
<input type="Button" name="" value=" x^y " onclick="calcula('E')">
<br>
Resultado:
<br>
<input type="Text" name="resultado" value="0" size="12">
</form>

</body>
</html>

<!DOCTYP
E html>
<html>
<head>
<title>Calculadora</title>
<meta charset="UTF-8">
<style type="text/css">
button {
width: 70px;
height: 30px;
}
input {
width: 360px;
height: 25px;
}
section {
padding: 2em;
width: 40%;
margin-left: 30%;
background: #CCC;
text-align: center;
height: 300px;
}
body {
text-align: center;
}
p{
font-weight: bold;
color: blue;
font-style: italic;
}
</style>
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript">
/*funcion de vaciado*/
$(function(){
$("#num").on("click",function(){
$("#num").val("");
});
});
/*funciones binarias*/
$(function(){
$("#bot_sumar").on("click",function(){
$("#acc").val($("#num").val());
$("#op").val("+");
});
});
$(function(){
$("#bot_restar").on("click",function(){
$("#acc").val($("#num").val());
$("#op").val("-");
});
});
$(function(){
$("#bot_multiplicar").on("click",function(){
$("#acc").val($("#num").val());
$("#op").val("*");
});
});
$(function(){
$("#bot_dividir").on("click",function(){
$("#acc").val($("#num").val());
$("#op").val("/");
});
});
$(function(){
$("#bot_elevary").on("click",function(){
$("#acc").val($("#num").val());
$("#op").val("y");
});
});
$(function(){
$("#bot_calcular").on("click",function(){
if($("#op").val()===
"+"){$("#num").val((+$("#acc").val())+(+$("#num").val()));}
if($("#op").val()=== "-"){$("#num").val((+$("#acc").val())-
(+$("#num").val()));}
if($("#op").val()===
"*"){$("#num").val((+$("#acc").val())*(+$("#num").val()));}
if($("#op").val()===
"/"){$("#num").val((+$("#acc").val())/(+$("#num").val()));}
if($("#op").val()===
"y"){$("#num").val(Math.pow((+$("#acc").val()),(+$("#num").val())));}
});
});
/*funciones unitarias*/
$(function(){
$("#bot_elevar2").on("click",function(){
$("#num").val((+$("#num").val())*(+$("#num").val()));
});
});
$(function(){
$("#bot_inverso").on("click",function(){
$("#num").val(1/(+$("#num").val()));
});
});
$(function(){
$("#bot_raiz").on("click",function(){
$("#num").val(Math.sqrt(+$("#num").val()));
});
});
$(function(){
$("#bot_entero").on("click",function(){
if($("#num").val()>0){$("#num").val(Math.floor(+$("#num").val()));}
if($("#num").val()<0){$("#num").val(Math.ceil(+$("#num").val()));}
});
});
$(function(){
$("#bot_potencia").on("click",function(){
$("#num").val(Math.pow(2,(+$("#num").val())));
});
});
$(function(){
$("#bot_factorial").on("click",function(){
var x = $("#num").val();
var total = x--;
while(x !== 0){
total = total * x--;
}
$("#num").val(total);
});
});
/*Operaciones con n operandos introducidos en formato CSV*/
$(function(){
$("#bot_sumatorio").on("click",function(){
var valores = $("#num").val().split(",");
var x = 0;
var total = 0;
while(x < valores.length){
total += +valores[x++];
}
$("#num").val(total);
});
});
$(function(){
$("#bot_producto").on("click",function(){
var valores = $("#num").val().split(",");
var x = 0;
var total = 1;
while(x < valores.length){
total = total * +valores[x++];
}
$("#num").val(total);
});
});
</script>
</head>
<body>
<h1>Buenos días, bienvenido a la calculadora de Jesús Angulo</h1>
<section>
<input type="hidden" id="op">
<input type="hidden" id="acc">
<input type="text" id="num">
<p> Operaciones binarias (con dos operandos):</p>
<button id="bot_sumar">+</button>
<button id="bot_restar">-</button>
<button id="bot_multiplicar">*</button>
<button id="bot_dividir">/</button>
<button id="bot_elevary">x<sup>y</sup></button>
<p> Operaciones unitarias (con un solo operando): </p>
<button id="bot_elevar2">x<sup>2</sup></button>
<button id="bot_inverso">1/x</button>
<button id="bot_raiz">&#8730;x</button>
<button id="bot_entero">entero(x)</button>
<button id="bot_potencia">2<sup>(x)</sup></button>
<button id="bot_factorial">x!</button>
<p> Operaciones con n operandos introducidos en formato CSV: </p>
<button id="bot_sumatorio">Sumatorio</button>
<button id="bot_producto">Producto</button>
<p>
<button id="bot_calcular" style="width:360px; background:
#39F;">Calcular</button>
</p>
</section>
<p>nota:
<ul>
<li><p>Para operaciones unitarias no hace falta presionar el botón
calcular, el resultado se genera de inmediato, por otro lado las
operaciones binarias requieren (colocar valor, presionar operador, colocar
segundo valor y presionar calcular)</li>
<li><p>Para realizar operaciones con n operandos introducidos en
formato CSV, se deben colocar los valores de la siguiente manera en la
caja: "a,b,c,d,e,f". La sumatoria devolvera la suma de todos los valores y
el producto su multiplicación.
</li>
</p>
</ul>
</body>
</html>

Das könnte Ihnen auch gefallen