Sunteți pe pagina 1din 6

<html>

<head>
<title>Pagina wed de bershy </title>
</head>
<body>
function daysBetween(date1, date2){
if (date1.indexOf("-") != -1) { date1 = date1.split("-"); } else if (date1.in
dexOf("/") != -1) { date1 = date1.split("/"); } else { return 0; }
if (date2.indexOf("-") != -1) { date2 = date2.split("-"); } else if (date2.in
dexOf("/") != -1) { date2 = date2.split("/"); } else { return 0; }
if (parseInt(date1[0], 10) >= 1000) {
var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
} else if (parseInt(date1[2], 10) >= 1000) {
var sDate = new Date(date1[2]+"/"+date1[0]+"/"+date1[1]);
} else {
return 0;
}
if (parseInt(date2[0], 10) >= 1000) {
var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
} else if (parseInt(date2[2], 10) >= 1000) {
var eDate = new Date(date2[2]+"/"+date2[0]+"/"+date2[1]);
} else {
return 0;
}
var one_day = 1000*60*60*24;
var daysApart = Math.abs(Math.ceil((sDate.getTime()-eDate.getTime())/one_day)
);
return daysApart;
}
</body>
<html>
----------------------------------------------------------------function getNumeroDeNits(){
var d1 = $('#datepicker1').val().split("-");
var dat1 = new Date(d1[2], parseFloat(d1[1])-1, parseFloat(d1[0]));
var d2 = $('#datepicker2').val().split("-");
var dat2 = new Date(d2[2], parseFloat(d2[1])-1, parseFloat(d2[0]));
var fin = dat2.getTime() - dat1.getTime();
var dias = Math.floor(fin / (1000 * 60 * 60 * 24))
return dias;
}
---------------------------------------------------------------------function dateDifference($d1, $d2){
$v1 = explode("-", $d1);
$date1 = mktime(0, 0, 0, intval($v1[1]), intval($v1[0]), intval($v1[2]));
$v2 = explode("-", $d2);
$date2 = mktime(0, 0, 0, intval($v2[1]), intval($v2[0]), intval($v2[2]));
$dateDiff = $date2 - $date1;
return floor($dateDiff/(60*60*24));
}

-------------------------------------------------------------1 function mostrarDias(){


2
3
var fechaInicio = document.getElementById("fechaInicio").value;
4
var fechaFin = document.getElementById("fechaFin").value;
5
6
if (fechaInicio.length != 10 || fechaFin.length != 10){
7
document.getElementById("diasDisfrutados").value = 0;
8
}
9
10
else{
11
12
//Separamos las fechas en dias, meses y aos
13
var diaInicio=fechaInicio.substring(0,2);
14
var mesInicio=fechaInicio.substring(3,5);
15
var anoInicio=fechaInicio.substring(6,10);
16
17
var diaFin=fechaFin.substring(0,2);
18
var mesFin=fechaFin.substring(3,5);
19
var anoFin=fechaFin.substring(6,10);
20
21
//Los meses empiezan en 0 por lo que le restamos 1
22
mesFin = mesFin -1;
23
mesInicio = mesInicio -1;
24
25
//Creamos una fecha con los valores que hemos sacado
26
var fInicio = new Date(anoInicio,mesInicio,diaInicio);
27
var fFin = new Date(anoFin,mesFin,diaFin);
28
29
diasTotal = 0;
30
31
if(fFin>fInicio){
32
33
//Para sumarle 365 das tienen que haber 2 aos de diferencia
34
//Si no solamente sumo los das entre meses
35
anoInicio++;
36
while(anoFin>anoInicio){
37
38
alert("Entro aqu si hay dos aos de diferencia");
39
40
if(esBisiesto(anoFin))
41
{
42
dias_e_anio=366;
43
}
44
else
45
{
46
dias_e_anio=365;
47
}
48
diasTotal = diasTotal + dias_e_anio;
49
anoFin--;
50
}
51
52
//Para sumarle los das de un mes completo, tengo que ver que haya
diferencia de 2 meses
53
mesInicio++;
54
while(mesFin>mesInicio){
55
dias_e_mes = getDays(mesFin-1,anoFin);
56
diasTotal = diasTotal + dias_e_mes;
57
mesFin--;
58
}

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
");
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

//Solamente falta sumar los das


mesInicio--;
if(mesInicio==mesFin){
diasTotal=diaFin-diaInicio+1;
}
else{
//Saco los das desde el mesInicio hasta fin de mes
dias_e_mes=getDays(mesInicio,anoInicio);
diasTotal = diasTotal + (dias_e_mes-diaInicio) +1;
//ahora saco los das desde el principio de mesFin hasta el da
diasTotal = diasTotal + parseInt(diaFin);
}
}
//Si la fechaFin es mayor
else if (fechaFin<fechaInicio){
alert("La fecha de fin no puede ser mayor que la fecha de inicio
diasTotal=0;
}
//Si las fechas son iguales
else{
diasTotal = 1;
}
}
}
function esBisiesto(ano) {
if (ano % 4 == 0)
return true
/* else */
return false
}
function getDays(month, year) {
var ar = new Array(12)
ar[0] = 31 // Enero
if(esBisiesto)
{
ar[1]=29
}
else
{
ar[1]=28
}
ar[2] = 31 // Marzo
ar[3] = 30 // Abril
ar[4] = 31 // Mayo
ar[5] = 30 // Junio
ar[6] = 31 // Julio
ar[7] = 31 // Agosto
ar[8] = 30 // Septiembre
ar[9] = 31 // Octubre
ar[10] = 30 // Noviembre

118
ar[11] = 31 // Diciembre
119
120
return ar[month];
121
}
--------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or


g/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Punto de venta Equipo de cmputo</title>
<script language="JavaScript" type="text/javascript">
function agregarFila()
{
var tbl = document.getElementById('TablaCalculadora');
var ultimaFila = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteracion = ultimaFila;
var filaactual = tbl.insertRow(ultimaFila);
// Primera celda
var primeracelda = filaactual.insertCell(0);
var textoNodo = document.createTextNode(iteracion);
primeracelda.appendChild(textoNodo);
//Segunda celda
var segundacelda = filaactual.insertCell(1);
var selector1 = document.createElement('select');
selector1.name = 'Descripcion' + iteracion;
selector1.id = 'Descripcion' + iteracion;
selector1.style.width= '200px';
selector1.options[0] = new Option('Equipo de escritorio', 'valor1');
selector1.options[1] = new Option('Servidor', 'valor2');
segundacelda.appendChild(selector1);
//Tercera celda
var terceracelda = filaactual.insertCell(2);
var selector2 = document.createElement('select');
selector2.name = 'precio' + iteracion;
selector2.id = 'precio' + iteracion;
selector2.style.width= '150px';
selector2.options[0] = new Option('1', 'valor0');
selector2.options[1] = new Option('2', 'valor1');
terceracelda.appendChild(selector2);
//Cuarta celda
var cuartacelda = filaactual.insertCell(3);
var selector3 = document.createElement('select');
selector3.id = 'cantidad' + iteracion;
selector3.name = 'cantidad' + iteracion;
selector3.style.width= '150px';
selector3.options[0] = new Option('1', 'valor0');
selector3.options[1] = new Option('2', 'valor1');
cuartacelda.appendChild(selector3);

//Quinta celda
var quintacelda = filaactual.insertCell(4);
var cuadrotexto1 = document.createElement('input');
cuadrotexto1.type = 'text';
cuadrotexto1.name = 'txtfila' + iteracion;
cuadrotexto1.id = 'txtfila' + iteracion;
cuadrotexto1.size = 20;
cuadrotexto1.disabled = 'disabled';
// cuadrotexto1.onkeypress = keyPressTest;
quintacelda.appendChild(cuadrotexto1);
}
function quitarFila()
{
var tbl = document.getElementById('TablaCalculadora');
var ultimaFila = tbl.rows.length;
if (ultimaFila > 2) tbl.deleteRow(ultimaFila - 1);
}
</script>
<script type="text/javascript">
_uacct = "UA-83058-1";
urchinTracker();
</script>
<script>
function consumo() {
var CantidadPrecio = document.getElementById('precio0').options.
selectedIndex;
var Precio = document.getElementById('precio0').options[Cantidad
Precio].text;
var CantidadTI = document.getElementById('cantidad0').options.se
lectedIndex;
var Cantidad = document.getElementById('cantidad0').options[Cant
idadTI].text;
document.getElementById('txtfila0').value = Precio * Cantidad;
}
</script>
</head>
<body>
<br>
<h1>Sistema</h1>
<hr>
<br>
<form action="Calculadora.html" method="get">
<input type="button" value="Agregar" onclick="agregarFila();"/>
<input type="button" value="Eliminar" onclick="quitarFila();" />
<table border="0" id="TablaCalculadora">
<tr>
<td>No.</td>
<td>Descripci&oacute;n</td>
<td>Precio Unitario</td>
<td>Cantidad de equipos</td>
<td>Subtotal</td>
</tr>
<tr>

<td>1</td>
<td>
<select name="Descripcion0" id="Descripcion0" style="width:200px
">
<option value="valor1">Equipo de escritorio</option>
<option value="valor2">Servidor</option>
</select>
</td>
<td>
<select name="precio0" id="precio0" style="width:150px">
<option value="valor1">1</option>
<option value="valor2">2</option>
</select>
</td>
<td>
<select name="cantidad0" id="cantidad0" style="width:150px" onbl
ur="javascript:consumo()">
<option value="valor1">1</option>
<option value="valor2">2</option>
</select>
</td>
<td>
<input type="text" name="txtfila0" id="txtfila0" size="20" disab
led="disabled"/>
</td>
</tr>
</table>
</form>
</body>
</html>

S-ar putea să vă placă și