jueves, 6 de octubre de 2011
UNEJEMPLO JOIN Y SPLIT EN JAVASCRIPT
<html>
<body>
<SCRIPT language="JavaScript">
function separa()
{
var c="NARANJA, /PERA, /UVAS, /PIÑA. ";
var a=c.split("/");
alert(a[0]+" "+a[1]+" "+a[2]+" "+a[3]);
}
</SCRIPT>
<SCRIPT language="JavaScript">
function pegar()
{
var nom = ['Am','ar','il','lo'];
var pegados = nom.join("");
alert(pegados);
}
</SCRIPT>
<FORM><p>
<H3>SPLIT<H3>
<INPUT TYPE="button" onClick="separa()" value="SEPARAR"><br><p>
<H3>JOIN<H3>
<INPUT TYPE="button" onClick="pegar()" value="PEGAR">
</FORM>
</body>
</html>
lunes, 26 de septiembre de 2011
una funcion de javascript desde select
<html>
<head>
<title>Ejemplo select</title>
<script language="JavaScript">
function dimePropiedades()
{
var texto
texto = "El numero de opciones del select: " + document.formul.seleccion.length
var indice = document.formul.seleccion.selectedIndex
texto += "\nIndice de la opción escogida: " + indice
var valor = document.formul.seleccion.options[indice].value
texto += "\nValor de la opcion escogida: " + valor
var textoEscogido = document.formul.seleccion.options[indice].text
texto += "\nTexto de la opcion escogida: " + textoEscogido
alert(texto)
}
</script>
</head>
<body>
<form name="formul">
Valoracion sobre esta pagina:
<select name="seleccion">
<option value="10">Muy bien
<option value="5" selected>Regular
<option value="0">Muy mal
</select>
<br>
<br>
<input type=button value="Dime propiedades" onclick="dimePropiedades()">
</form>
</body>
</html>
<head>
<title>Ejemplo select</title>
<script language="JavaScript">
function dimePropiedades()
{
var texto
texto = "El numero de opciones del select: " + document.formul.seleccion.length
var indice = document.formul.seleccion.selectedIndex
texto += "\nIndice de la opción escogida: " + indice
var valor = document.formul.seleccion.options[indice].value
texto += "\nValor de la opcion escogida: " + valor
var textoEscogido = document.formul.seleccion.options[indice].text
texto += "\nTexto de la opcion escogida: " + textoEscogido
alert(texto)
}
</script>
</head>
<body>
<form name="formul">
Valoracion sobre esta pagina:
<select name="seleccion">
<option value="10">Muy bien
<option value="5" selected>Regular
<option value="0">Muy mal
</select>
<br>
<br>
<input type=button value="Dime propiedades" onclick="dimePropiedades()">
</form>
</body>
</html>
ver o ocultar una informacion
<html>
<head>
<script type="text/javascript">
function mostrar(mo)
{
document.getElementById(mo).style.display= "block";
}
function ocultar(ocu)
{
document.getElementById(ocu).style.display= "none";
}
function inicial()
{
if (document.getElementById('pepema'))
{
mostrar('text1') ;
}
else
{
ocultar('text1');
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body,td,th {
font-size: 18px;
color: #000;
}
body {
background-image: url(curso%20del%20sena/vxcvxcvxzcx);
}
-->
</style></head>
<body onLoad="inicial()">
<table border="5" align="center">
<tr>
<td bgcolor="#FFCC66">
<a href="javascript:mostrar('text1')">ver entarda</a>
<br>
<div id='text1'><img align="10" alt="10" src="GIF018.gif "><br>
<strong>hay un secreto que debemos mostra</strong><br>
<strong>quieres ver para que me vuelva a ver</strong><br>
<strong>se que te gustara lo veras.</strong></div>
<a href="javascript:ocultar('text1')">ocultar entarda</a>
</td>
</tr>
</table>
</body>
</html>
<head>
<script type="text/javascript">
function mostrar(mo)
{
document.getElementById(mo).style.display= "block";
}
function ocultar(ocu)
{
document.getElementById(ocu).style.display= "none";
}
function inicial()
{
if (document.getElementById('pepema'))
{
mostrar('text1') ;
}
else
{
ocultar('text1');
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body,td,th {
font-size: 18px;
color: #000;
}
body {
background-image: url(curso%20del%20sena/vxcvxcvxzcx);
}
-->
</style></head>
<body onLoad="inicial()">
<table border="5" align="center">
<tr>
<td bgcolor="#FFCC66">
<a href="javascript:mostrar('text1')">ver entarda</a>
<br>
<div id='text1'><img align="10" alt="10" src="GIF018.gif "><br>
<strong>hay un secreto que debemos mostra</strong><br>
<strong>quieres ver para que me vuelva a ver</strong><br>
<strong>se que te gustara lo veras.</strong></div>
<a href="javascript:ocultar('text1')">ocultar entarda</a>
</td>
</tr>
</table>
</body>
</html>
El dolor es inevitable, el sufrimiento es opcional.
Amar es enamorarse de la misma persona todos los días, sin hacer antigüedad, evitando la monotonía.
Siempre en el amor hay un poco de locura pero en la locura hay un poco de razón.
No importa el exterior... tampoco el interior.
El amor no es fantasía, el amor es poesía y es por eso que te digo que yo te amaría, aunque tú no me quieras.
Si quieres saber cuanto te quiero cuenta las estrellas del cielo...
No me hagas llorar, me acostumbro a que ya no estas y, aunque no quiera, lo admitiré ya que es la verdad...
El amor es una condición en la que la felicidad de otra persona es condición imprescindible para su propia felicidad.
Sé que no puedo volar, pero hay alguien que me hace sentir que lo puedo hacer, y esa persona eres tú.
lunes, 19 de septiembre de 2011
Este ejemplo contempla un mostrador de diapositivas (en este caso imágenes). Se tienen dos enlaces, uno mostrar la diapositiva siguiente y otro para mostrar la diapositiva anterior. Una posible aplicación práctica podría ser en una galería de fotos.
<html>
<head>
<title>Ejemplo de un mostrador de diapositivas</title>
<script>
var contador = 0;
var diapositivas = [];
function inicio()
{
var contenedor = document.getElementById("diapositivas");
while (contenedor.childNodes.length > 0)
{
if (contenedor.getElementsByTagName("img")[0]==contenedor.firstChild)
{
diapositivas[diapositivas.length] = contenedor.removeChild( contenedor .firstChild);
}
else contenedor.removeChild(contenedor.firstChild);
}
}
function adelante()
{
contador++;
if (contador >= diapositivas.length) contador = 0;
ponerImagen()
}
function atras()
{
contador--;
if (contador < 0 ) contador = diapositivas.length - 1;
ponerImagen();
}
function ponerImagen()
{
var contenedor = document.getElementById("diapositivas");
if (contenedor.childNodes.length==0)
contenedor.appendChild(diapositivas[contador]);
else contenedor.replaceChild(diapositivas[contador], contenedor.childNodes[0]);
}
</script>
</head>
<body>
<a href="javascript: atras();">Atrás</a>
<span id="diapositivas">
<img src="arx1299975097t.gif" alt="Diapositiva 1" height="100" width="200">
<img src="bwy1296591260p.gif" alt="Diapositiva 2" height="100" width="200">
<img src="images.jpg" alt="Diapositiva 3" height="100" width="200">
</span>
<a href="javascript: adelante();">Adelante </a>
</body>
</html>
<script>
inicio();
ponerImagen();
</script>
<head>
<title>Ejemplo de un mostrador de diapositivas</title>
<script>
var contador = 0;
var diapositivas = [];
function inicio()
{
var contenedor = document.getElementById("diapositivas");
while (contenedor.childNodes.length > 0)
{
if (contenedor.getElementsByTagName("img")[0]==contenedor.firstChild)
{
diapositivas[diapositivas.length] = contenedor.removeChild( contenedor .firstChild);
}
else contenedor.removeChild(contenedor.firstChild);
}
}
function adelante()
{
contador++;
if (contador >= diapositivas.length) contador = 0;
ponerImagen()
}
function atras()
{
contador--;
if (contador < 0 ) contador = diapositivas.length - 1;
ponerImagen();
}
function ponerImagen()
{
var contenedor = document.getElementById("diapositivas");
if (contenedor.childNodes.length==0)
contenedor.appendChild(diapositivas[contador]);
else contenedor.replaceChild(diapositivas[contador], contenedor.childNodes[0]);
}
</script>
</head>
<body>
<a href="javascript: atras();">Atrás</a>
<span id="diapositivas">
<img src="arx1299975097t.gif" alt="Diapositiva 1" height="100" width="200">
<img src="bwy1296591260p.gif" alt="Diapositiva 2" height="100" width="200">
<img src="images.jpg" alt="Diapositiva 3" height="100" width="200">
</span>
<a href="javascript: adelante();">Adelante </a>
</body>
</html>
<script>
inicio();
ponerImagen();
</script>
Se muestra una versión simplificada del problema limitada tan sólo al lado del cliente. Para ello es necesario imaginarse un sistema en línea donde se suben ficheros al servidor, ejemplo de ello podría ser una aplicación de correo electrónico.
<html>
<head>
<title> ejemplo para adjuntar multiplies ficheros </title>
<script language="javascript" type="text/javascript">
function nuevofichero()
{
var input = document.getElementsByTagName("input")[0];
var nuevoInput = input.cloneNode(true);
input.parentNode.appendChild(nuevoInput);
}
</script>
</head>
<body>
<form name="ejemplos de ficheros" method="post" enctype="multipart/form-data">
<fieldset><legend>adjuntar multiples de ficheros</legend>
<input name="ficheros[]" type="file"size="60"></fieldset>
<a href="javascript: nuevoFichero();">Adjuntar otro fichero</a>
<input name="Subir" type="submit" value="Adjuntar">
</form>
</body>
</html>
<head>
<title> ejemplo para adjuntar multiplies ficheros </title>
<script language="javascript" type="text/javascript">
function nuevofichero()
{
var input = document.getElementsByTagName("input")[0];
var nuevoInput = input.cloneNode(true);
input.parentNode.appendChild(nuevoInput);
}
</script>
</head>
<body>
<form name="ejemplos de ficheros" method="post" enctype="multipart/form-data">
<fieldset><legend>adjuntar multiples de ficheros</legend>
<input name="ficheros[]" type="file"size="60"></fieldset>
<a href="javascript: nuevoFichero();">Adjuntar otro fichero</a>
<input name="Subir" type="submit" value="Adjuntar">
</form>
</body>
</html>
viernes, 16 de septiembre de 2011
relacion en mysql
-- phpMyAdmin SQL Dump
-- version 2.10.3
--
-- Servidor: localhost
-- Tiempo de generación: 16-09-2011 a las 10:35:40
-- Versión del servidor: 5.0.51
-- Versión de PHP: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ ZERO";
--
-- Base de datos: `votando`
--
-- ------------------------------ --------------------------
--
-- Estructura de tabla para la tabla `candidato`
--
CREATE TABLE `candidato` (
`cdcandidato` bigint(50) NOT NULL,
`nomcandidato` varchar(50) NOT NULL,
`apecandidato` varchar(50) NOT NULL,
`numtargeton` bigint(50) NOT NULL,
`foto` varchar(50) NOT NULL,
PRIMARY KEY (`cdcandidato`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcar la base de datos para la tabla `candidato`
--
-- ------------------------------ --------------------------
--
-- Estructura de tabla para la tabla `login`
--
CREATE TABLE `login` (
`codusuario` bigint(50) NOT NULL,
`usuario` varchar(50) NOT NULL,
`passw` varchar(50) NOT NULL,
PRIMARY KEY (`usuario`),
KEY `codusuario` (`codusuario`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcar la base de datos para la tabla `login`
--
-- ------------------------------ --------------------------
--
-- Estructura de tabla para la tabla `usuario`
--
CREATE TABLE `usuario` (
`codusuario` bigint(50) NOT NULL,
`nomusuario` varchar(50) NOT NULL,
`apeusuario` varchar(50) NOT NULL,
PRIMARY KEY (`codusuario`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcar la base de datos para la tabla `usuario`
--
-- ------------------------------ --------------------------
--
-- Estructura de tabla para la tabla `votacion`
--
CREATE TABLE `votacion` (
`codusuario` bigint(50) NOT NULL,
`cdcandidato` bigint(50) NOT NULL,
`fechavoto` datetime NOT NULL,
KEY `cdcandidato` (`cdcandidato`),
KEY `codusuario` (`codusuario`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcar la base de datos para la tabla `votacion`
--
--
-- Filtros para las tablas descargadas (dump)
--
--
-- Filtros para la tabla `login`
--
ALTER TABLE `login`
ADD CONSTRAINT `login_ibfk_1` FOREIGN KEY (`codusuario`) REFERENCES `usuario` (`codusuario`);
--
-- Filtros para la tabla `votacion`
--
ALTER TABLE `votacion`
ADD CONSTRAINT `votacion_ibfk_2` FOREIGN KEY (`cdcandidato`) REFERENCES `candidato` (`cdcandidato`),
ADD CONSTRAINT `votacion_ibfk_1` FOREIGN KEY (`codusuario`) REFERENCES `usuario` (`codusuario`);
martes, 13 de septiembre de 2011
Por medio de una tabla mostrar una imagen a la vez y cambiarla de acuerdo al checkbox utilizado.
<html>
<head>
<title>cambiar imagenes</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var imageNum = 1
image1 = new Image()
image1.src = "img/unchecked.gif"
image2 = new Image()
image2.src = "img/amistad.gif"
function cambiar(id)
{
if ( imageNum == 1 )
{
document.getElementById('checkbox_'+id).src = image2.src
imageNum = 2
}
else
{
document.getElementById('checkbox_'+id).src = image1.src
imageNum = 1
}
}
//
</SCRIPT>
<table BORDER="5" WIDTH="10%" ALIGN="CENTER">
<tr>
<th width="180" align="center"><a href="Javascript:cambiar('1')""><img id="checkbox_1" name="checkbox_1" src="img/unchecked.gif" width="100" height="85" border="1"></a>
<br>
<a href="Javascript:cambiar('2')""><img id="checkbox_2" name="checkbox_2" src="img/amistad.gif" width="100" height="85" border="1"></a></th>
</tr>
</table>
</body>
</html>
<head>
<title>cambiar imagenes</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var imageNum = 1
image1 = new Image()
image1.src = "img/unchecked.gif"
image2 = new Image()
image2.src = "img/amistad.gif"
function cambiar(id)
{
if ( imageNum == 1 )
{
document.getElementById('checkbox_'+id).src = image2.src
imageNum = 2
}
else
{
document.getElementById('checkbox_'+id).src = image1.src
imageNum = 1
}
}
//
</SCRIPT>
<table BORDER="5" WIDTH="10%" ALIGN="CENTER">
<tr>
<th width="180" align="center"><a href="Javascript:cambiar('1')""><img id="checkbox_1" name="checkbox_1" src="img/unchecked.gif" width="100" height="85" border="1"></a>
<br>
<a href="Javascript:cambiar('2')""><img id="checkbox_2" name="checkbox_2" src="img/amistad.gif" width="100" height="85" border="1"></a></th>
</tr>
</table>
</body>
</html>
En una nueva página capturar un nombre y mostrarlo en la misma página concatenando con la fecha del sistema.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- PRIMER PASO: Copiar este formulario en el archivo prev1.htm -->
<form type="get" action="prev2.htm">
<div align="left"><table border="1" bgcolor="#00FFFF" cellspacing="0" cellpadding="0"
width="250">
<tr>
<td width="80"><small><font face="Arial">Nombre:</font></small></td>
<td width="170"><input type="text" name="nombre" size="14"></td>
</tr>
<tr>
<td width="80"><small><font face="Arial">Apellido:</font></small></td>
<td width="170"><input type="text" name="apellido" size="14"></td>
</tr>
<tr>
<td bgcolor="#000000" width="80"> </td>
<td bgcolor="#000000" width="170"><small><font face="Arial">
<input type="submit" value="ACCEDER"></font></small></td>
</tr>
</table>
</div>
</form>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/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>Documento sin título</title>
</head>
<!-- SEGUNDO PASO: Copiar este script en el archivo prev2.htm -->
<!-- Dentro de HEAD -->
<script LANGUAGE="JavaScript">
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
</script>
<!-- Dentro de BODY -->
<script LANGUAGE="JavaScript">
nombre = unescape(params["nombre"]);
apellido = unescape(params["apellido"]);
email = unescape(params["email"]);
document.write("Nombre = " + nombre + "<br>");
document.write("Apellido = " + apellido + "<br>");
</script>
<script> document.write(new Date())
</script>
<body>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- PRIMER PASO: Copiar este formulario en el archivo prev1.htm -->
<form type="get" action="prev2.htm">
<div align="left"><table border="1" bgcolor="#00FFFF" cellspacing="0" cellpadding="0"
width="250">
<tr>
<td width="80"><small><font face="Arial">Nombre:</font></small></td>
<td width="170"><input type="text" name="nombre" size="14"></td>
</tr>
<tr>
<td width="80"><small><font face="Arial">Apellido:</font></small></td>
<td width="170"><input type="text" name="apellido" size="14"></td>
</tr>
<tr>
<td bgcolor="#000000" width="80"> </td>
<td bgcolor="#000000" width="170"><small><font face="Arial">
<input type="submit" value="ACCEDER"></font></small></td>
</tr>
</table>
</div>
</form>
en la segunda pagina
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/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>Documento sin título</title>
</head>
<!-- SEGUNDO PASO: Copiar este script en el archivo prev2.htm -->
<!-- Dentro de HEAD -->
<script LANGUAGE="JavaScript">
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
</script>
<!-- Dentro de BODY -->
<script LANGUAGE="JavaScript">
nombre = unescape(params["nombre"]);
apellido = unescape(params["apellido"]);
email = unescape(params["email"]);
document.write("Nombre = " + nombre + "<br>");
document.write("Apellido = " + apellido + "<br>");
</script>
<script> document.write(new Date())
</script>
<body>
</body>
</html>
Ejemplo de trabajo con los métodos
<html>
<head>
</head>
<body>
function validaSubmite()
{
if (document.miFormulario.campo1.value == "")
alert("Debe rellenar el formulario")
else
document.miFormulario.submit()
}
if (document.miFormulario.campo1.value == "")
alert("Debe rellenar el formulario")
else
document.miFormulario.submit()
}
<form name="miFormulario" action="mailto:promocion@guiarte.com" enctype="text/plain">
<input type="Text" name="campo1" value="" size="12">
<input type="button" value="Enviar" onclick="validaSubmite()">
</form>
<input type="Text" name="campo1" value="" size="12">
<input type="button" value="Enviar" onclick="validaSubmite()">
</form>
</body>
</html>
lunes, 12 de septiembre de 2011
en una pagina ingresamos los datos para que en la otra nos muestre los datos ingresado
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- PRIMER PASO: Copiar este formulario en el archivo prev1.htm -->
<form type="get" action="prev2.htm">
<div align="left"><table border="1" bgcolor="#00FFFF" cellspacing="0" cellpadding="0"
width="250">
<tr>
<td width="80"><small><font face="Arial">Nombre:</font></small></td>
<td width="170"><input type="text" name="nombre" size="14"></td>
</tr>
<tr>
<td width="80"><small><font face="Arial">Apellido:</font></small></td>
<td width="170"><input type="text" name="apellido" size="14"></td>
</tr>
<tr>
<td bgcolor="#000000" width="80"> </td>
<td bgcolor="#000000" width="170"><small><font face="Arial">
<input type="submit" value="ACCEDER"></font></small></td>
</tr>
</table>
</div>
</form>
nos lleva a otra pagina y nos muestra los datos que hemos ingresados con la fecha actual
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/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>Documento sin título</title>
</head>
<!-- SEGUNDO PASO: Copiar este script en el archivo prev2.htm -->
<!-- Dentro de HEAD -->
<script LANGUAGE="JavaScript">
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
</script>
<!-- Dentro de BODY -->
<script LANGUAGE="JavaScript">
nombre = unescape(params["nombre"]);
apellido = unescape(params["apellido"]);
email = unescape(params["email"]);
document.write("Nombre = " + nombre + "<br>");
document.write("Apellido = " + apellido + "<br>");
</script>
<script> document.write(new Date())
</script>
<body>
</body>
</html>
viernes, 9 de septiembre de 2011
como utilizar el header para regercionar otra pagina
<?php
include("conexion.php");
if(isset($ok))
{
if($usuario=="" || $contrasena=="")
{
$mensajes=" datos en blanco";
}
}
?>
<html>
<body>
<form name="contrasena1.php" method="post" action="">
usuario: <input type="text" name="usuario">
<br><br>
contrasena: <input type="password" name="contrasena">
<br> <br>
<input type="submit" name="ok" value="iniciar sesion">
</form>
<?php
echo "$mensajes";
?>
</body>
</html>
include("conexion.php");
if(isset($ok))
{
if($usuario=="" || $contrasena=="")
{
$mensajes=" datos en blanco";
}
}
?>
<html>
<body>
<form name="contrasena1.php" method="post" action="">
usuario: <input type="text" name="usuario">
<br><br>
contrasena: <input type="password" name="contrasena">
<br> <br>
<input type="submit" name="ok" value="iniciar sesion">
</form>
<?php
echo "$mensajes";
?>
</body>
</html>
si tienes la edad suficiente para ingresar si o no a una empresa
<html>
<head>
</head>
<body>
<form name="edad.php" method="post">
(*)nombre <input type="text" name="nombre">
<br>
(*)cedula <input type="text" name="cedula">
<br>
(*)edad <input type="text" name="edad">
<br>
<input type="submit" name="boton1" value="ingresar dato">
</from>
<?php
if(($nombre=="")||($cedula="")||($edad=""))
{
if($edad>=18 && $edad<=30)
{
echo " tienes la edad suficiente para registrarse";
}
else
{
echo "no tienes la edad sificiente para registrarse";
}
}
else
{
echo "los campos marcados con(*) son obligatorios ";
}
?>
</body>
</html>
<head>
</head>
<body>
<form name="edad.php" method="post">
(*)nombre <input type="text" name="nombre">
<br>
(*)cedula <input type="text" name="cedula">
<br>
(*)edad <input type="text" name="edad">
<br>
<input type="submit" name="boton1" value="ingresar dato">
</from>
<?php
if(($nombre=="")||($cedula="")||($edad=""))
{
if($edad>=18 && $edad<=30)
{
echo " tienes la edad suficiente para registrarse";
}
else
{
echo "no tienes la edad sificiente para registrarse";
}
}
else
{
echo "los campos marcados con(*) son obligatorios ";
}
?>
</body>
</html>
ejercicios de select en php
<html>
<head>
</head>
<body>
<form name="" method="post" action="select.php">
ingrese el primer valor:
<input type="text" name="text1">
ingrese el segundo valor:
<input type="text" name="text2">
seleccione la operacion
<select name="select1">
<option value="sumar">suma</option>
<option value="resta">resta</option>
</select>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if($_request['select1']=="suma")
{
$suma=$_request['text1']+$_request['text2'];
echo "la suma es:$suma";
}
if($_request['select1']=="resta")
{
$dif=$_request['text1']-$_request['text2'];
echo "la suma es:$dif";
}
?>
</body>
</html>
<head>
</head>
<body>
<form name="" method="post" action="select.php">
ingrese el primer valor:
<input type="text" name="text1">
ingrese el segundo valor:
<input type="text" name="text2">
seleccione la operacion
<select name="select1">
<option value="sumar">suma</option>
<option value="resta">resta</option>
</select>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if($_request['select1']=="suma")
{
$suma=$_request['text1']+$_request['text2'];
echo "la suma es:$suma";
}
if($_request['select1']=="resta")
{
$dif=$_request['text1']-$_request['text2'];
echo "la suma es:$dif";
}
?>
</body>
</html>
ejercicios de radio php
<html>
<head>
</head>
<body>
<form name="" method="post" action="radio.php">
ingrese el primer valor:
<input type="text" name="text1">
<br><br>
ingrese el segundo valor:
<input type="text" name="text2">
<br>
<input type="radio" name="radio1">
sumar
<br>
<input type="radio" name="radio1">
restar
<br>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if($_request['radio1']=="suma")
{
$resultado=$_request['text1']+$_request['text2'];
}
if($_request['radio1']=="resta")
{
$resultado=$_request['text1']-$_request['text2'];
}
echo "el resultaso es:$resultado";
?>
</body>
</html>
<head>
</head>
<body>
<form name="" method="post" action="radio.php">
ingrese el primer valor:
<input type="text" name="text1">
<br><br>
ingrese el segundo valor:
<input type="text" name="text2">
<br>
<input type="radio" name="radio1">
sumar
<br>
<input type="radio" name="radio1">
restar
<br>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if($_request['radio1']=="suma")
{
$resultado=$_request['text1']+$_request['text2'];
}
if($_request['radio1']=="resta")
{
$resultado=$_request['text1']-$_request['text2'];
}
echo "el resultaso es:$resultado";
?>
</body>
</html>
ejercicios de checkbox
<html>
<head>
</head>
<body>
<form name="" method="post" action="checkbox.php">
ingrese el primer valor:
<input type="text" name="text1">
ingrese el segundo valor:
<input type="text" name="text2">
<br>
<input type="checkbox" name="checkbox1">
sumar
<br>
<input type="checkbox" name="checkbox2">
restar
<br>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if(isset($_request['checkbox1']=="suma")
{
echo " la suma es:$suma<br>";
}
if(isset($_request['checkbox1']=="resta")
{
echo " la resta es:$dif<br>";
}
?>
</body>
</html>
<head>
</head>
<body>
<form name="" method="post" action="checkbox.php">
ingrese el primer valor:
<input type="text" name="text1">
ingrese el segundo valor:
<input type="text" name="text2">
<br>
<input type="checkbox" name="checkbox1">
sumar
<br>
<input type="checkbox" name="checkbox2">
restar
<br>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if(isset($_request['checkbox1']=="suma")
{
echo " la suma es:$suma<br>";
}
if(isset($_request['checkbox1']=="resta")
{
echo " la resta es:$dif<br>";
}
?>
</body>
</html>
funciones de como hacer una suma
<html>
<head>
<title>Documento sin título</title>
</head>
<body>
<form name="funcion.php" method="post" action="">
digite el primer valor<input type="text" name="uno">
<br><br>
digite el segundo valor<input type="text" name="dos">
<br> <br>
<input type="submit" name="botton" value="aceptar">
</form>
<?php
if($_REQUEST[botton] != "")
{
$r= suma($uno, $dos);
echo "$r";
}
function suma($uno, $dos)
{
$result = $uno + $dos;
return($result);
}
?>
</body>
</html>
<head>
<title>Documento sin título</title>
</head>
<body>
<form name="funcion.php" method="post" action="">
digite el primer valor<input type="text" name="uno">
<br><br>
digite el segundo valor<input type="text" name="dos">
<br> <br>
<input type="submit" name="botton" value="aceptar">
</form>
<?php
if($_REQUEST[botton] != "")
{
$r= suma($uno, $dos);
echo "$r";
}
function suma($uno, $dos)
{
$result = $uno + $dos;
return($result);
}
?>
</body>
</html>
como subir una imagen a un servidor
<html>
<head><title> como subir una imagen a un servidor</title>
</head
<body>
<p> </p>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<label>
<br />
Nombre: <input type="text" name="nom" value="" />
<br />
<br />
Detalle: <input type="text" name="det" value="" />
<br />
<br />
Imagen:
<br />
<input type="file" name="imagen" id="fileField" />
<br />
<input type="submit" name="boton1" value="enviar" />
</label>
</form>
<p> </p>
<?php
if (isset($_REQUEST['boton1']))
{
$upload_dir= "img/";
$nombre= $_REQUEST['nom'];
$detalle= $_REQUEST['det'];
$upload_dir_file= $upload_dir.$_FILES['imagen']['name'];
$imagen= $_FILES['imagen']['name'];
if (move_uploaded_file($_FILES['imagen']['tmp_name'],$upload_dir_file))
{
include("conexion.php");
$sql = "insert into aprendiz (nombre,detalle,imagen) values('$nombre','$detalle','$imagen')";
mysql_query($sql, $conex) or die ("error en la consulta");
}
else echo "error";
}
?>
</body>
</html>
llamando desde otro archivo la conexion
<?php
$server = localhost;
$user = root;
$pass = sena;
$bd = adsi;
$conex= mysql_connect("localhost","root","sena")or die ("NO se pudo realizar la conexion");
mysql_select_db("$bd",$conex);
?>
<head><title> como subir una imagen a un servidor</title>
</head
<body>
<p> </p>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<label>
<br />
Nombre: <input type="text" name="nom" value="" />
<br />
<br />
Detalle: <input type="text" name="det" value="" />
<br />
<br />
Imagen:
<br />
<input type="file" name="imagen" id="fileField" />
<br />
<input type="submit" name="boton1" value="enviar" />
</label>
</form>
<p> </p>
<?php
if (isset($_REQUEST['boton1']))
{
$upload_dir= "img/";
$nombre= $_REQUEST['nom'];
$detalle= $_REQUEST['det'];
$upload_dir_file= $upload_dir.$_FILES['imagen']['name'];
$imagen= $_FILES['imagen']['name'];
if (move_uploaded_file($_FILES['imagen']['tmp_name'],$upload_dir_file))
{
include("conexion.php");
$sql = "insert into aprendiz (nombre,detalle,imagen) values('$nombre','$detalle','$imagen')";
mysql_query($sql, $conex) or die ("error en la consulta");
}
else echo "error";
}
?>
</body>
</html>
llamando desde otro archivo la conexion
<?php
$server = localhost;
$user = root;
$pass = sena;
$bd = adsi;
$conex= mysql_connect("localhost","root","sena")or die ("NO se pudo realizar la conexion");
mysql_select_db("$bd",$conex);
?>
miércoles, 7 de septiembre de 2011
implementar un programa que permita en el servidor realizar la suma, resta con dos enteros pidiendo selección de múltiples ioperaciones en forma simultanea
<html>
<head>
</head>
<body>
<form name="" method="post" action="checkbox.php">
ingrese el primer valor:
<input type="text" name="text1">
ingrese el segundo valor:
<input type="text" name="text2">
<br>
<input type="checkbox" name="checkbox1">
sumar
<br>
<input type="checkbox" name="checkbox2">
restar
<br>
<input type="submit" name="boton1" value="operar">
</form>
<?php
if(isset($_request['checkbox1']=="suma")
{
echo " la suma es:$suma<br>";
}
if(isset($_request['checkbox1']=="resta")
{
echo " la resta es:$dif<br>";
}
?>
</body>
</html>
martes, 6 de septiembre de 2011
<HTML>
<SCRIPT language=JavaScript>
function changecolor(code) {
document.bgColor=code }
</SCRIPT>
<BODY bgColor=#ffffff>
<CENTER>
<H1>Evento "onMouseOver"</H1></CENTER>
<HR>
<A onmouseover="changecolor('ffffff')" href="http://www.misena.edu.co">
<IMG height=20 hspace=10 src="Using_onMouseOver_archivos/white.gif" width=20 vspace=10>
</A>
<A onmouseover="changecolor('ff0000')" href="http://www.">
<IMG height=20 hspace=10 src="Using_onMouseOver_archivos/red.gif" width=20 vspace=10>
</A>
<A onmouseover="changecolor('ffff00')" href="http://www.">
<IMG height=20 hspace=10 src="Using_onMouseOver_archivos/yellow.gif" width=20 vspace=10>
</A>
<A onmouseover="changecolor('009900')" href="http://www.">
<IMG height=20 hspace=10 src="Using_onMouseOver_archivos/green.gif" width=20 vspace=10>
</A>
<A onmouseover="changecolor('0000ff')" href="http://www.">
<IMG height=20 hspace=10 src="Using_onMouseOver_archivos/blue.gif" width=20 vspace=10>
</A>
<HR>
</BODY>
</HTML>
Suscribirse a:
Comentarios (Atom)










