Ver Mensaje Individual
  #9 (permalink)  
Antiguo 05/01/2009, 12:07
darkmcloud
 
Fecha de Ingreso: octubre-2007
Mensajes: 191
Antigüedad: 16 años, 7 meses
Puntos: 0
Respuesta: Javascript que ejecuta otro javascript

Código asp:
Ver original
  1. <html>
  2. <meta http-equiv="Expires" content="0">
  3. <meta http-equiv="cache-control" content="no-store">
  4. <head><title>Consulta de Facturas</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
  6. <!--
  7. body,td,th {
  8.     color: #FFFFFF;
  9. }
  10. body {
  11.     background-image: url(images/2.jpg);
  12. }
  13. -->
  14. </style></head>
  15. <body onLoad="document.frmClientes.rut.focus();" >
  16. <SCRIPT LANGUAGE="JAVASCRIPT">
  17.  
  18. function validar(form)
  19. {
  20. var error = "POR FAVOR, ANTES DE ENVIAR EL FORMULARIO, DEBE COMPLETAR LOS SIGUIENTES CAMPOS:\n\n";
  21. var a = ""
  22.  
  23.     if (form.rut.value == "") { a += "RUT \n"; }
  24.       if (form.razon.value == "") { a += "RAZON SOCIAL\n"; }
  25.     if (form.folio.value == "") { a += "FOLIO FACTURA\n"; }
  26.     if (form.orden.value == "") { a += "Nº PEDIDO\n"; }
  27.      
  28.  
  29.    
  30.    
  31.     if (a != "") { alert(error + a); return true; }
  32.  insertar()
  33. }
  34.  
  35.  
  36.       function insertar() {
  37.  
  38.           var formulario = document.getElementById("frmClientes");
  39.  
  40.           formulario.action='insert_clientes.asp?rut=' + document.getElementById("rut").value +
  41.                              '&razon=' + document.getElementById("razon").value +
  42.  
  43.                              '&folio=' + document.getElementById("folio").value +
  44.  
  45.                              '&fecha=' + document.getElementById("fecha").value +
  46.                    '&orden=' + document.getElementById("orden").value;
  47.  
  48.           formulario.method="POST";
  49.  
  50.           formulario.submit();
  51.  
  52.       }
  53.  
  54.  
  55.  
  56.     </SCRIPT>
  57.  
  58.  
  59.  
  60.  
  61.       <form name="frmClientes" id="frmClientes" method="post" action="facturas_final.asp" autocomplete  = "off">
  62.  
  63.  
  64.       <td width="120" ><input name="rut" id="rut" value="<%=rut%>"> </td>
  65.  
  66.       <%if session("rut") <>9999-9 then%>
  67.  
  68.       <td width="250"><input name="razon" id="razon" value="<%=razon%>" size=50></td>
  69.  
  70.       <td width="120"><input name="folio" id="folio" value="<%=folio%>" size=20 ></td>
  71.  
  72.       <td width="120"><input name="fecha" id="fecha" value="<%=fecha_actual%>" readonly size=20 ></td>
  73.  
  74.       <td width="202"><input name="orden" id="orden" value="<%=orden%>" size=20></td>  
  75.  
  76.  
  77.    
  78.    
  79.     <tr>
  80.      
  81.       <td colspan="2" align=left>
  82.         <p>
  83.            
  84.           <input name="submit" type="submit" value="Buscar">
  85.  
  86. </td>
  87.    
  88.  
  89.  
  90.      <td colspan="2" align=left>
  91.    
  92.  <input type="button" value="Terminar" onClick="validar(this.form)">
  93.    
  94.     </td>
  95.    
  96.      </tr>
  97.   </table>
  98. </FORM>
  99. </body>
  100. </html>

perdon compadre...me habia equivocado en postear el codigo...pero lo hice como dijiste tu..(lo que pasa es que tenia 2 paginas que se llamaban casi =....
el error al parecer lo da cuando tendria que ejecutarse el insertar()...porque al menos comprueba bien que esten todos los campos con datos...

el error lo da en la linea 40...donde esta:
formulario.submit();
de antemano muchas gracias

Última edición por darkmcloud; 05/01/2009 a las 12:25