ozwolverine Posted February 9, 2007 Share Posted February 9, 2007 Hello everybody, I have a problem javascript related. I have a popup that has: one textbox and a select list, when the select changes I throw a submit(); I have a javascript function that first checks if both the textbox was filled and the select has change its value, and depending on that it constructs (using java script) another pop up that will show some number sequences. The problem is that in my environment (Linux, php5.2.0, Oracle9i) it works perfectly well, so I mounted on another (in our client's machines) environment (Linux, php5.0.4, mssql) and it doesn't work. In client's system, after I make a selection in the select, it submits the page, but it returns some of the javascript code in the same popup. Let me explain with some code: this is the whole page code: <? /** * Metodo alternativo para radicacion masiva * @author Johnny Gonzalez * @version 1.0 */ error_reporting(7); session_start(); $ruta_raiz = "../../"; //include( "$ruta_raiz/debugger.php" ); require_once("$ruta_raiz/include/db/ConnectionHandler.php"); //Si no llega la dependencia recupera la sesi�n if(!isset($_SESSION['dependencia'])) { include "$ruta_raiz/rec_session.php"; } if (!$db) $db = new ConnectionHandler($ruta_raiz); //$db->conn->debug = true; $phpsession = session_name()."=".session_id(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../../estilos/orfeo.css"> <script language="JavaScript"> <!-- function advertencia( cantidadRegistros, form ) { var confirmaSecuencias = confirm( "Seguro que desea generar " + cantidadRegistros + " secuencias para radicacion masiva?\nEl proceso no se puede revertir y seria necesario realizar la anulacion manual de todos los radicados generados." ); if( confirmaSecuencias ){ <? $arreglo = array(); //var_dump("Tipo rad" . $tipoRad); if ( $tipoRad && ( $cantidadRegistros != '' || $cantidadRegistros != null ) ){ require_once("$ruta_raiz/class_control/Dependencia.php"); $objDependecia = new Dependencia($db); $objDependecia->Dependencia_codigo($dependencia); $cursor = & $db; $cuenta = 0; // var_dump( "Cantidad" . $cantidadRegistros ); while ( $cuenta < $cantidadRegistros ) { // var_dump("Cuenta" . $cuenta ); $secRadicacion="secr_tp".$tipoRad."_".$objDependecia->getSecRadicTipDepe($dependencia,$tipoRad); $sec=$cursor->nextId($secRadicacion); $sec = str_pad($sec,6,"0",STR_PAD_LEFT); $arreglo[] = date("Y").$dependencia.$sec.substr($secRadicacion,7,1); $cuenta++; } $cadena = ""; ?> alert( "Se generaron las " + cantidadRegistros + " secuencias entre el <?=$arreglo[ 0 ] ?> y el <?=$arreglo[ $cuenta - 1 ] ?>, a continuacion apareceran en una ventana aparte,\npara que las copie a una hoja de calculo."); ventana=window.open(' ','secuenciasMasiva','menubar=no,scrollbars=yes,width=300,height=500'); ventana.opener=self; ventana.document.write("<HTML>"); ventana.document.write("<HEAD><TITLE>Secuencias para Radicación Masiva</TITLE></HEAD>"); ventana.document.write("<BODY><CENTER>"); <? foreach ( $arreglo as $numeroRadicado ) { $cadena.="<br>$numeroRadicado"; } ?> ventana.document.write("<?=$cadena?>"); ventana.document.write("</CENTER></BODY>"); ventana.document.write("</HTML>"); ventana.document.close(); <? $confirmado = true; require_once $ruta_raiz."/class_control/class_controlExcel.php"; $controlSec = new CONTROL_ORFEO($db); if ($arreglo[ 1 ] != null || $arreglo[ 1 ] != '') { $intervaloSecuencia = $arreglo[ 1 ] - $arreglo[ 0 ]; }else { $intervaloSecuencia = 0; } $resultadoInsertaSec = $controlSec -> insertaSecuencias( $arreglo[ 0 ], $arreglo[ $cuenta - 1 ], $intervaloSecuencia, $dependencia, $codusuario, $tipoRad ); if( !$resultadoInsertaSec ){ ?> alert("Se produjo un error insertando los datos de las secuencias."); <? } }else{ ?> alert("Debe seleccionar el tipo de radicacion."); return false; <? } ?> }else{ // alert("No confirma"); // submit(); } // alert("Sale"); form.submit(); } function valida( form ){ // alert("entra" + document.frmGeneraSecuenciasMasiva.cantidadRegistros.value); // alert("entra 2"); var cantidad = document.frmGeneraSecuenciasMasiva.cantidadRegistros.value; if( cantidad == "" ){ alert( "Para generar las secuencias debe ingresar la cantidad." ); return false; }else{ // alert("no NULL"); advertencia( cantidad, form ); return true; } } function f_close(){ window.close(); } function Start(URL, WIDTH, HEIGHT) { windowprops = "top=0,left=0,location=no,status=no, menubar=no,scrollbars=yes, resizable=yes,width="; windowprops += WIDTH + ",height=" + HEIGHT; preview = window.open(URL , "preview", windowprops); } //--> </script> </head> <body bgcolor="#FFFFFF" topmargin="0"> <form name="frmGeneraSecuenciasMasiva" action='generarSecuencias.php?<?=$phpsession ?>&krd=<?=$krd?>&<? echo "fechah=$fechah"; ?>' method="POST"> <table width="75%" align="center" border="0" cellpadding="0" cellspacing="5" class="borde_tab"> <tr> <td height="25" class="titulos4" colspan="2">RADICACIÓN MASIVA DE DOCUMENTOS (Generación de Secuencias)</td> </tr> <tr align="center" > <td class="listado2" colspan="2"> La radicación requiere la generación de las secuencias para los radicados, si desea generarlas, <br>ingrese la cantidad de registros a procesar y haga click en Generar, de lo contario en Cerrar. </td> </tr> <tr align="center"> <td class="listado2" > Cantidad de Registros </a> </td> <td class="listado2" > <input type="text" name="cantidadRegistros" value="<?=$cantidadRegistros?>" size="5" maxlength="3"> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <table width="31%" align="center" border="0" cellpadding="0" cellspacing="5" class="borde_tab"> <tr align="center"> <td height="25" colspan="2" class="titulos4">TIPO DE RADICACIóN</td> </tr> <tr align="center"> <td width="16%" class="titulos2">Seleccione: </td> <td width="84%" height="30" class="listado2"> <?php $cad = "USUA_PRAD_TP"; // Creacion del combo de Tipos de radicado habilitados seg�n permisos $sql = "SELECT SGD_TRAD_CODIGO,SGD_TRAD_DESCR FROM SGD_TRAD_TIPORAD WHERE SGD_TRAD_GENRADSAL > 0"; //Buscamos los TRAD En la entidad $Vec_Trad = $db->conn->GetAssoc($sql); $Vec_Perm = array(); while (list($id, $val) = each($Vec_Trad)) { $sql = "SELECT ".$cad.$id." FROM USUARIO WHERE USUA_LOGIN='".$krd."'"; $rs2 = $db->conn->Execute($sql); if ($rs2->fields[$cad.$id] > 0) { $Vec_Perm[$id] = $val; } } //print_r($Vec_Perm); reset($Vec_Perm); ?> <select name="tipoRad" id="Slc_Trd" class="select" onchange="submit();"> <option value="0">Seleccione una opción</option> <? while (list($id, $val) = each($Vec_Perm)) { if($tipoRad==$id) $datoss = " selected "; else $datoss=""; echo " <option value=".$id." $datoss>$val</option>"; } ?> </select> </td> </tr> </table> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <center> <input type="button" value="Generar" class="botones" onclick="valida(this.form);"> </center> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <center> <input class="botones" type=button name=Cerrar id=Cerrar Value=Cerrar onclick='f_close()'> </center> </td> </tr> </table> </form> </body> </html> The generated code of the page when the popup is loaded for the first time is: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../../estilos/orfeo.css"> <script language="JavaScript"> <!-- function advertencia( cantidadRegistros, form ) { var confirmaSecuencias = confirm( "Seguro que desea generar " + cantidadRegistros + " secuencias para radicacion masiva?\nEl proceso no se puede revertir y seria necesario realizar la anulacion manual de todos los radicados generados." ); if( confirmaSecuencias ){ alert("Debe seleccionar el tipo de radicacion."); return false; }else{ } form.submit(); } function valida( form ){ var cantidad = document.frmGeneraSecuenciasMasiva.cantidadRegistros.value; if( cantidad == "" ){ alert( "Para generar las secuencias debe ingresar la cantidad." ); return false; }else{ advertencia( cantidad, form ); return true; } } function f_close(){ window.close(); } function Start(URL, WIDTH, HEIGHT) { windowprops = "top=0,left=0,location=no,status=no, menubar=no,scrollbars=yes, resizable=yes,width="; windowprops += WIDTH + ",height=" + HEIGHT; preview = window.open(URL , "preview", windowprops); } //--> </script> </head> <body bgcolor="#FFFFFF" topmargin="0"> <form name="frmGeneraSecuenciasMasiva" action='generarSecuencias.php?PHPSESSID=172o16o0o121oUSUARIO2&krd=USUARIO2&fechah=20070209040210' method="POST"> <table width="75%" align="center" border="0" cellpadding="0" cellspacing="5" class="borde_tab"> <tr> <td height="25" class="titulos4" colspan="2">RADICACIÓN MASIVA DE DOCUMENTOS (Generación de Secuencias)</td> </tr> <tr align="center" > <td class="listado2" colspan="2"> La radicación requiere la generación de las secuencias para los radicados, si desea generarlas, <br>ingrese la cantidad de registros a procesar y haga click en Generar, de lo contario en Cerrar. </td> </tr> <tr align="center"> <td class="listado2" > Cantidad de Registros </a> </td> <td class="listado2" > <input type="text" name="cantidadRegistros" value="" size="5" maxlength="3"> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <table width="31%" align="center" border="0" cellpadding="0" cellspacing="5" class="borde_tab"> <tr align="center"> <td height="25" colspan="2" class="titulos4">TIPO DE RADICACIóN</td> </tr> <tr align="center"> <td width="16%" class="titulos2">Seleccione: </td> <td width="84%" height="30" class="listado2"> <select name="tipoRad" id="Slc_Trd" class="select" onchange="submit();"> <option value="0">Seleccione una opción</option> <option value=2 >Entrada</option> <option value=5 >Resolucion</option> </select> </td> </tr> </table> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <center> <input type="button" value="Generar" class="botones" onclick="valida(this.form);"> </center> </td> </tr> <tr align="center"> <td class="listado2" colspan="2" > <center> <input class="botones" type=button name=Cerrar id=Cerrar Value=Cerrar onclick='f_close()'> </center> </td> </tr> </table> </form> </body> </html> but when I change the value of the select, after submit it shows me this code, see screenshot: It seems like instead of creating the javascript source it tries to put it as part of the actual page (html) code. The original popup is: The popup after the submit of the onchange is: What could the problem be? I guess it is not a client problem, because after the code didn't work I used the same machine in the client company to connect to the version I have working in my company, and it worked, so I think it is a problem of the PHP version, in my environment I have 5.2.0 the client has 5.0.4, A friend tried in php 5.1.6 and it didn't work there either Any ideas?? Could this be a possible bug? Thanks a lot, Johnny Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.