Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/12/2007, 12:32
o2kr
 
Fecha de Ingreso: diciembre-2007
Mensajes: 15
Antigüedad: 17 años, 2 meses
Puntos: 0
Problema Formato Rut y Funcion

Bueno tengo un problema en un input
Código PHP:
<FORM ACTION="index.php" method="POST" class="style6">
        <
TABLE width="238">
          <
TR>
            <
TD width="108" class="style11"><div align="right"><span class="style13">R.U.T.:</span></div></TD>
            <
TD width="118" class="style11"><INPUT NAME="rut22" TYPE="text" SIZE="10" MAXLENGTH="20" onblur="this.value = formato_rut(this.value, true)">
              <
input type="image" style="" src="imagenes/bot_lupa1.gif" name="accion22" value="Buscar" >              </a></TD>
          </
TR>
        </
TABLE>
      </
FORM
tengo eso que autorellena el rut con puntos y el guion
La funcion es esta a la que llama:

Código PHP:
<script>
function 
formato_rut(textoactivo) {
var 
invertido "";
var 
dtexto "";
var 
cnt 0;
var 
i=0;
var 
j=0;
var 
largo "";    
    if (
activo) {
          
texto formato_rut(textofalse)
          
largo texto.length;
          for ( 
i=(largo-1),j=0i>=0i--,j++ )
            
invertido invertido texto.charAt(i);          
          
dtexto dtexto invertido.charAt(0);
          
dtexto dtexto '-';          
          for ( 
i=1,j=2i<largoi++,j++ )
          {
            
//alert("i=[" + i + "] j=[" + j +"]" );
            
if ( cnt == )
            {
              
dtexto dtexto '.';
              
j++;
              
dtexto dtexto invertido.charAt(i);
              
cnt 1;
            }
            else
            { 
              
dtexto dtexto invertido.charAt(i);
              
cnt++;
            }
          }
          
invertido "";
          for ( 
i=(dtexto.length-1),j=0i>=0i--,j++ )
            
invertido invertido dtexto.charAt(i);
          if (
invertido == '-'invertido ""
          
texto invertido;
    } else {
        var 
tmpstr "";
        for ( 
i=0texto.length i++ )
        if ( 
texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
            
tmpstr tmpstr texto.charAt(i);
        
texto tmpstr;
    }
    return 
texto;
}
</script> 
Lo malo es q no me funciona lo siguiente porque al ingresar el rut y ya haberlo arreglado y al apretar el boton deberian entrarme a la siguiente sentencia pero no lo hace ( no hace nada ) no tira ningun mensaje ( se actualiza la pagina no mas ) :

Código PHP:
 include ('bddef.php');
if (isset (
$_POST['rut']))
{
$rut $_POST['rut'];
//$rut =strtoupper(ereg_replace('\.|,|-','',$rut));
$sql="select * from cliente where RUT='$rut'";
$result mysql_query($sql,$dbc);
$row mysql_fetch_assoc($result);
    if(
$row)
    {
    echo 
"<b>Nº SOCIO: </b>".$row['NSOCIO']." <b>RUT:</b> ".$row['RUT']." <b>NOMBRE:</b> ".$row['NOMBRE']." <b>SU PUNTAJE ES:</b> ".$row['PTOS'];
    }else{
    echo 
"Rut No Ingresado en Nuestra Base de Datos";
    } 

Espero que me puedan ayudar de antemanos Muchas Gracias