Foros del Web » Programando para Internet » Javascript »

problemas

Estas en el tema de problemas en el foro de Javascript en Foros del Web. les pido de su ayuda. Tengo el siguinete codigo: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!--<script src = "javascripts.js"></script>--> <link rel="stylesheet" href="estilo.css" type="text/css"> ...
  #1 (permalink)  
Antiguo 11/12/2003, 20:05
 
Fecha de Ingreso: noviembre-2003
Ubicación: mexico
Mensajes: 41
Antigüedad: 20 años, 5 meses
Puntos: 0
problemas

les pido de su ayuda. Tengo el siguinete codigo:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--<script src = "javascripts.js"></script>-->
<link rel="stylesheet" href="estilo.css" type="text/css">
<script languaje="javascript">
function revisar()
{
faltantes = "";
if (document.datos.bascula.value == "")
{
faltantes += "\n - Bascula.";
}
if(document.datos.paterno.value == "")
{
faltantes += "\n - Apellido Paterno.";
}
if(document.datos.materno.value == "")
{
faltantes += "\n - Apellido Paterno.";
}
if(document.datos.localidad.value == "")
{
faltantes += "\n - Localidad.";
}
if(document.datos.municipio.value == "")
{
faltantes += "\n - Municipio.";
if(document.datos.entrevistado.value == "")
{
faltantes += "\n - Entrevistado.";
}
if(document.datos.integrantes.value == "")
{
faltantes += "\n - Integrantes.";
}
if (faltantes!="")
{
faltantes ="_____________________________\n" +
"Te ha faltado introducir los siguientes datos:\n" +
faltantes + "\n_____________________________" +
"\n¡Por favor rellena los datos!";
alert(faltantes);
}
faltantes1="";
if(document.datos.calle.value == "")
{
faltantes += "\n - Integrantes.";
}
if(document.datos.manzana.value == "")
{
faltantes += "\n - Manzana.";
}
if(document.datos.lote.value == "")
{
faltantes += "\n - Lote.";
}
if(document.datos.numero.value == "")
{
faltantes += "\n - Numero.";
}
if (faltantes1!="")
{
resp=confirm(Falta cierta informacion (no obligatoria).¿Quieres efectuar la alta?);
if(resp)
{
submit();
}
}
else
{
resp=confirm(¿Quieres efectuar la alta?);
if(resp)
{
submit();
}
}
}
</script>
</head>
<body bgcolor=#eeffee link=#339933 >
<script language="JavaScript">
hexColor = ["0","1","2","3","4","5","6","7","8","9","a","b","c ","d","e","f"];
function mOver() {
for (i = 0; i < 13; i++) {
setTimeout('document.datos.registrar.style.backgro und = "#'+hexColor[12-i]+'0'+hexColor[12-i]+'0c0";', i * 40);
}
}
function mOut() {
document.datos.registrar.value = "Registrar";
for (i = 0; i < 12; i++) {
setTimeout('document.datos.registrar.style.backgro und = "#'+hexColor[i]+'0'+hexColor[i]+'0c0";', i * 40);
}
}
function mOver1() {
for (i = 0; i < 13; i++) {
setTimeout('document.datos.limpiar.style.backgroun d = "#'+hexColor[12-i]+'0'+hexColor[12-i]+'0c0";', i * 40);
}
}
function mOut1() {
document.datos.limpiar.value = "Limpiar";
for (i = 0; i < 12; i++) {
setTimeout('document.datos.limpiar.style.backgroun d = "#'+hexColor[i]+'0'+hexColor[i]+'0c0";', i * 40);
}
}
colours=new Array('#ff0000','#00ff00','#ffffff','#ff00ff','#ff a500','#ffff00','#00ff00','#ffffff','ff00ff')
n = 10;
y = 0;
x = 0;
n6=(document.getElementById&&!document.all);
ns=(document.layers);
ie=(document.all);
d=(ns||ie)?'document.':'document.getElementById("' ;
a=(ns||n6)?'':'all.';
n6r=(n6)?'")':'';
s=(ns)?'':'.style';
if (ns){
for (i = 0; i < n; i++)
document.write('<layer name="dots'+i+'" top=0 left=0 width='+i/2+' height='+i/2+' bgcolor=#ff0000></layer>');
}
if (ie)
document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
if (ie||n6){
for (i = 0; i < n; i++)
document.write('<div id="dots'+i+'" style="position:absolute;top:0px;left:0px;width:'+ i/2+'px;height:'+i/2+'px;background:#ff0000;font-size:'+i/2+'"></div>');
}
if (ie)
document.write('</div></div>');
(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
y = (ns||n6)?evnt.pageY+4 - window.pageYOffset:event.y+4;
x = (ns||n6)?evnt.pageX+1:event.x+1;
}
(ns)?window.onMouseMove=Mouse:document.onmousemove =Mouse;
function animate(){
o=(ns||n6)?window.pageYOffset:0;
if (ie)con.style.top=document.body.scrollTop;
for (i = 0; i < n; i++){
var temp1 = eval(d+a+"dots"+i+n6r+s);

randcolours = colours[Math.floor(Math.random()*colours.length)];
(ns)?temp1.bgColor = randcolours:temp1.background = randcolours;
if (i < n-1){
var temp2 = eval(d+a+"dots"+(i+1)+n6r+s);
temp1.top = parseInt(temp2.top);
temp1.left = parseInt(temp2.left);
}
else{
temp1.top = y+o;
temp1.left = x;
}
}
setTimeout("animate()",10);
}
animate();
// -->
</script>
<table border=1 cellspacing=0 width=100% align=center>
<tr>
<td class=encabezado>
ENCUESTA INTEGRAL DE SERVICIOS (BANCO DE ALIMENTOS)
</td>
</tr>
</table>
<H3>DATOS GENERALES</H3>
<hr align="center" noshade>
<form name="datos" method="post" action="php_datos.php" submit="return revisar();">
<table align="center" width=95%>
<tr>
<td class = informacion width="35%">Folio:</td>
<td class = captura width="17%">
<?php
include("folio.php");
$folio=consecutivo();
echo "<b>$folio</b>";
?>
</td>
<td class=informacion width="30%" >Fecha:</td>
<td class=informacion width="18%">
<?php echo "<b>",date("d-m-Y"),"</b>" ?>
</td>
</tr>
<tr>
<td class=informacion width="35%"> Numero de bascula:</td>
<td class=informacion width="17%">
<input type="text" name="bascula" size = "4" onKeypress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;">
</td>
<td class=informacion width="30%"> Localidad:</td>
<td class=informacion width="18%">
<input type="text" name="localidad" size="15" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33)){} else event.returnValue=false;">
</td>
</tr>
<tr>
<td class=otro width="35%" > Direccion:</td>
</tr>
<tr>
<td class=informacion width="35%"> Calle: </td>
<td class=informacion width="17%"><tt><font face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="calle" size="20" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33) || (CH>=48 && CH<=57 )){} else event.returnValue=false;">
</font></tt> </td>
<td class=informacion width="30%">
<p><tt><font face="Verdana, Arial, Helvetica, sans-serif">Municipio: </font></tt></p>
</td>
<td class=informacion width="18%">
<input type="text" name="municipio" size="15" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33)){} else event.returnValue=false;">
</td>
</tr>
<tr>
<td class=informacion width="35%">Manzana:</td>
<td class=informacion width="17%">
<input type="text" name="manzana" size="4" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">
</td>
<td class=informacion width="30%">Nombre del entrevistado:</td>
<td class=informacion width="18%">
<input type="text" name="entrevistado" size="20" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33)){} else event.returnValue=false;">
</td>
</tr>
<tr>
<td class=informacion width="35%">Lote:</td>
<td class=informacion width="17%">
<input type="text" name="lote" size="4" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">
</td>
<td class=informacion width="30%">Area:</td>
<td class=informacion width="18%">
<select size="1" name="area">
<option>Area 01 Cabecera</option>
<option>Area 02 Rural</option>
</select>
</td>
</tr>
<tr>
<td class=informacion width="35%">Numero:</td>
<td class=informacion width="17%">
<input type="text" name="numero" size="4" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">
</td>
</tr>
<tr>
<td class=otro width="35%">Nombre de la familia:</td>
</tr>
<tr>
<td class=informacion width="35%"> Apellido Paterno:</td>
<td width="17%" >
<input type="text" name="paterno" size="10" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33)){} else event.returnValue=false;">
</td>
<td class=informacion width="30%"> &iquest;Numero de integrantes de la familia?
</td>
<td class=informacion width="18%">
<input type="text" name="integrantes" size="3" onKeypress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;">
</td>
</tr>
<tr>
<td class=informacion height="41" width="35%">Apellido Paterno:</td>
<td class=informacion height="41" width="17%">
<input type="text" name="materno" size="10" onKeypress="CH=event.keyCode; if ((CH >= 65 && CH <= 90) || (CH >= 97 && CH <= 122) || (CH > 31 && CH < 33)){} else event.returnValue=false;">
</td>
</tr>
</table>
<table width="95%" border="0" align=center>
<tr>
<td class=boton>
<input type="submit" name="registrar" value="Registrar" onMouseOver='mOver()' onMouseOut='mOut()'>
</td>
<td class=boton>
<input type="reset" name="limpiar" value="Limpiar" onMouseOver='mOver1()' onMouseOut='mOut1()'>
</td>
</tr>
</table>
</form>
</body>
</html>

Resulta que quiero confirmar los datos de envio, al momento de cargar la pagina me merca un error de que falta un parentesis que cierra, ya revise bien el codigo pero no lo encuentro y como consecuencia no aparece el mensaje de confirmacion. Les agradezco de antemano su gran ayuda
  #2 (permalink)  
Antiguo 14/12/2003, 11:55
Avatar de tunait
Moderadora
 
Fecha de Ingreso: agosto-2001
Ubicación: Terok Nor
Mensajes: 16.805
Antigüedad: 22 años, 8 meses
Puntos: 381
Faltaban algunas comillas en un par de lugares y algunas cosillas más que he ido tocando a medida que se quejaba.

Ahora funciona, te pongo sólo la parte del script que verifica

Código:
<script languaje="javascript">
function revisar() 
{
faltantes = "";
if (document.datos.bascula.value == "") 
{
faltantes += "\n - Bascula.";
}
if(document.datos.paterno.value == "") 
{
faltantes += "\n - Apellido Paterno.";
}
if(document.datos.materno.value == "") 
{
faltantes += "\n - Apellido Paterno.";
}
if(document.datos.localidad.value == "") 
{
faltantes += "\n - Localidad.";
}
if(document.datos.municipio.value == "") 
{
faltantes += "\n - Municipio.";
if(document.datos.entrevistado.value == "") 
{
faltantes += "\n - Entrevistado.";
}
if(document.datos.integrantes.value == "") 
{
faltantes += "\n - Integrantes.";
}
if (faltantes!="")
{
faltantes ="_____________________________\n" +
"Te ha faltado introducir los siguientes datos:\n" +
faltantes + "\n_____________________________" +
"\n¡Por favor rellena los datos!";
alert(faltantes);
}
faltantes1="";
if(document.datos.calle.value == "") 
{
faltantes += "\n - Integrantes.";
}
if(document.datos.manzana.value == "") 
{
faltantes += "\n - Manzana.";
}
if(document.datos.lote.value == "") 
{
faltantes += "\n - Lote.";
}
if(document.datos.numero.value == "") 
{
faltantes += "\n - Numero.";
}
if (faltantes1!="")
{
return confirm('Falta cierta informacion (no obligatoria).¿Quieres efectuar la alta?')

}
else
{
return confirm('¿Quieres efectuar la alta?')
}
} 
}
</script>
y a tu form le pones

<form name="datos" method="post" action="php_datos.php" onsubmit=" return revisar();">


Última edición por tunait; 14/12/2003 a las 11:57
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:08.