Ir al contenido principal

materiales

unidad 1
w3c  |   aulafàcil html   |    html  |  editor


unidad 2
javascript  |   w3c   |  programaciòn web
diseño de documentos
mapas conceptuales




unidad 3
lenguajes de internet |  conexión a bd   |  mysql   |




programas javascript

marzo 16
<html>
    <head>
        <title>ciclos en JavaScript</title>
    </head>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">Numero :</label>
        <input type="text" id="txtN1">
        <br><br>
        <input type="button" onclick="Sumar();" value="Suma">
    </fieldset>
    </body>
    <script>
        function Sumar() {
            var n2 = document.getElementById('txtN1').value;
            sum=0;
            for(i=1;i<n2;i=i+1){
              sum=sum+i; 
             } 
                document.write("suma " +sum)
        }

    </script>


marzo 9

<html>
    <head>
        <title>condicional en JavaScript</title>
    </head>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">Numero 1:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">Numero 2:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Comparar();" value="Comparar">
    </fieldset>
    </body>
    <script>
        function Comparar() {
            var n1 = document.getElementById('txtN1').value;
            var n2 = document.getElementById('txtN2').value;
            if (n1>n2){
                alert("el primer operando es mayor que el segundo")}
            else
               {alert("el primer operando no es mayor que el segundo")}
        }
    </script>
</html>
____________________________________________________________________________________

<html>
    <head>
        <title>comparaciòn de nùmeros</title>
    </head>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">Numero 1:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">Numero 2:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Comparar();" value="Comparar">
    </fieldset>
    </body>
    <script>
        function Comparar() {
            var n1 = document.getElementById('txtN1').value;
            var n2 = document.getElementById('txtN2').value;
            if (n1>n2){
                document.write("el primer operando es mayor que el segundo ")}
            else
               { document.write("el primer operando no es mayor que el segundo ")}
        }
    </script>


</html>
_____________________________________________________________________________________

ejercicios:

1) hacer la comparación con 3 números

2) corregir el programa siguiente

<html>
    <head>
        <title>càlculo del total</title>
    </head>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">Numero 1:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">Numero 2:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Calcular();" value="Calcula">
    </fieldset>
    </body>
    <script>
        function Calcular() {
            var n1 = document.getElementById('txtN1').value;
            var n2 = document.getElementById('txtN2').value;
            var n3 = n1*n2;
            document.write("total a pagar: "+n3)
        }
    </script>

</html>






_____________________________________________________________________________________
<html>
    <head>
        <title>Sumar dos Numeros JavaScript</title>
    </head>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">Numero 1:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">Numero 2:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Sumar();" value="Calcular">
    </fieldset>
    </body>
    <script>
        function Sumar() {
            var n1 = document.getElementById('txtN1').value;
            var n2 = document.getElementById('txtN2').value;
            var suma = parseInt(n1) + parseInt(n2);
            alert("La suma es: "+suma)
        }
    </script>

</html>
_________________________________________________________

<html>
    <head>
        <title>imprime cadena</title>
    </head>
    <body>

    </body>
    <script>

     document.write("hola");
    </script>
</html>
_________________________________________________________

<html>
    <head>
        <title>imprime cadena</title>
    </head>
    <body>

    </body>
    <script>
     var prueba = "algo aqui";
     document.write(prueba);
    </script>
</html>
_______________________________________________________

<html>
    <head>
        <title>imprime cadena</title>
    </head>
    <body>
    <fieldset>
        <legend>nombre </legend>
        <label for="">nombre:</label>
        <input type="text" id="txtN1">
        <br><br>
        <input type="button" onclick="Saludar();" value="saludar">
    </fieldset>
    </body>
    <script>
        function Saludar() {
          var n1 = document.getElementById('txtN1').value;
          document.write("hola "+n1);
        }
    </script>
</html>
_______________________________________________________    

<html>
    <head>
        <title>imprime cadena</title>
    </head>
    <body>
    <fieldset>
        <legend>programa saludo </legend>
        <label for="">nombre:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">apellido:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Saludar();" value="saludar">
    </fieldset>
    
    </body>

    <script>
        function Saludar() {
          var n1 = document.getElementById('txtN1').value;
          var n2 = document.getElementById('txtN2').value;
            document.write("hola "+n1+" "+n2);
        }
    </script>
</html>



<html>
    <head>
        <title>potencia de un nùmero</title>
        <title>potencia de un nùmero</title>
    </head>
        <h1>programa potencia</h1>
    <body>
    <fieldset>
        <legend>Ingrese dos numeros</legend>
        <label for="">base:</label>
        <input type="text" id="txtN1">
        <br><br>
        <label for="">exponente:</label>
        <input type="text" id="txtN2">
        <br><br>
        <input type="button" onclick="Potencia();" value="Calcular">
    </fieldset>
    </body>
    <script>
        function Potencia() {
            var n1 = document.getElementById('txtN1').value;
            var n2 = document.getElementById('txtN2').value;
            var potencia = Math.pow(parseInt(n1), parseInt(n2)); 
            alert("el resultado es: "+potencia)
        }
    </script>
</html>



  




Comentarios

Entradas populares de este blog