viernes, 28 de agosto de 2015

php comprobar fecha correcta validar fecha

if (isset($_GET['fecha']))
{
    $aux=$_GET['fecha'];
    $vector=explode("/",$_GET['fecha']);
   
    if (sizeof($vector)==3)
    {
        $fechaOK=true;
       
        if (checkdate ( (int)$vector[1] , (int)$vector[0] , (int)$vector[2]) == true)
            echo "ok";
        else
            echo "mal";
    }
}







.

lunes, 24 de agosto de 2015

llamada AJAX con valores

    //*****************************
    function posicion()
    {
        var urlServidor = "http://36.200.18.11:8889/pau/phonegap/mapa.php";
       
        var auxd = localStorage.getItem("diaLocal");
        var auxm = localStorage.getItem("mesLocal");
        var auxa = localStorage.getItem("anyoLocal");
       
        var auxd = "23";
        var auxm = "8";
        var auxa = "2015";
       
        var vars1 = { anyo: auxa, mes: auxm, dia: auxd , pass: pass };
        var vars2 = { anyo: auxa, mes: auxm, dia: auxd , pass: pass, coche: cocheId };
       
        //** si no solicita un coche sino ... el else
        if (cocheId=="")
        {
            $.get(urlServidor, vars1, function(data){
            setPosicion(data);    // es un metodo propio
            });
        }
        else
        {
            $.get(urlServidor, vars2, function(data){
            setPosicion(data);
            });
        }
    }
   

viernes, 21 de agosto de 2015

llamada AJAX v2

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script>
var datosExternos="";
var
someurl = "http://37.186.181.110:8889/borrar/salida.php";

$.get(someurl, function(data){
  datosExternos=data;
});

//************************
function saluda()
{
alert(datosExternos);
}

</script>
</head>
<body>

<button onclick="saluda();"> PROBAR </button>

</body>
</html>










.

llamada AJAX (si funciona con phonegap no funciona desde el PC)

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>

$(document).ready(function()
{

var someurl = "http://37.186.181.110:8889/borrar/salida.php";

$("#info").load(someurl);
});



</script>
</head>
<body>


<div id="info"></div>


</body>
</html>





.






jueves, 20 de agosto de 2015

JQUERY Calendario

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script src="cal_es.js"></script>
 
  <script>
$(document).ready(function(){ 
    $( "#datepicker" ).datepicker();
   
    $("#btn1").click(function(){
        $( "#fecha" ).text($( "#datepicker" ).val());
    });
});
 
 
 

  </script>
</head>
<body>


<div id="datepicker"></div>
<div id="fecha"></div>
<button id="btn1"> ACPETAR </button>




</body>
</html>

martes, 18 de agosto de 2015

centrar texto en vertical en un div

    height: 65px;
    line-height: 65px;








.

poner 3 div en horizontal uno al lado del otro

    <style>
    .fechaDiv
    {
    padding-bottom: 5px;
    padding-left: 5px;
    padding-right: 5px;
    padding-top: 5px;
    width: 65px;
    height: 65px;
    line-height: 65px;
    border: 1px solid #000000;
    font-size: 25px;
    background-color: #9BCD9B;
    }
   
    #container{width:100%;}
    #dia{float:left;}
    #anyo{float:right;}
    #mes{margin:0 auto;}
   
    </style>
   
    <div id="container">
    <div id="dia" class="fechaDiv"></div>
    <div id="anyo" class="fechaDiv"></div>
    <div id="mes" class="fechaDiv"></div>   
    </div>

phonegap comprobar conexion a internet

<!DOCTYPE html>
<html>
  <head>
    <title>navigator.connection.type Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    //
    function onDeviceReady() {
        checkConnection();
    }

        function checkConnection() {
            var networkState = navigator.connection.type;

            var states = {};
            states[Connection.UNKNOWN]  = 'Unknown connection';
            states[Connection.ETHERNET] = 'Ethernet connection';
            states[Connection.WIFI]     = 'WiFi connection';
            states[Connection.CELL_2G]  = 'Cell 2G connection';
            states[Connection.CELL_3G]  = 'Cell 3G connection';
            states[Connection.CELL_4G]  = 'Cell 4G connection';
            states[Connection.CELL]     = 'Cell generic connection';
            states[Connection.NONE]     = 'No network connection';

            alert('Connection type: ' + states[networkState]);
           
            if (states[networkState]=='WiFi connection')
            alert("te sale gratis");
           
        }

    </script>
  </head>
  <body>
    <p>A dialog box will report the network state.</p>
  </body>
</html>



.

phonegap saber si rota la pantalla

<!DOCTYPE html>
<html>
    <head>

    <script>

    function mi_funcion(){ window.addEventListener('orientationchange',  rotacion,  false); }

    function rotacion() {
    if(orientation==90 || orientation==-90)  alert('horizontal');
    else                alert('vertical');
    }
    mi_funcion();


</script>

<body>

</body>

</html>




.