css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <head>
	<meta charset="utf-8">
	<title>Transacciones Bancarias</title>
</head>
<body>
	<h1>Transacciones bancarias</h1>

	</div>
		<h2>Cuenta del usuario</h2>
		<p><b>Número de cuenta:</b> ES12 1234 1234 01 0123456789</p>
		<div id="cuenta_usuario"><p><b>Saldo:</b> 1000 €</p></div><hr/>
	</div>
	<div>
		<h2>Cuenta de destino</h2>
		<p><b>Número de cuenta:</b> ES21 4321 4321 10 9876543210 </p>
		<div id="cuenta_destino"><p><b>Saldo:</b> 1000 €</p></div><hr/>		
	</div>
	<div>
		<form id="formulario" name="formulario" > 
			<p>Transferir <input type="number" id="dinero" name="dinero" min="0" max="999"/> €  desde la cuenta del usuario a la cuenta de destino.
			<input type="button" value="Ordenar transaccion" id="b_aceptar" onclick="comprobar();" /></p>
			<hr/>
		</form>
	</div>

	<div>
		<h2>Movimientos</h2>
		<div id="movimientos"></div><hr/>
	</div>
</body>
</html>
            
          
!
            
              html,
body {
  background-color: #DDDDDD;
  margin: 0px;
  padding: 5px;
  padding-top: 30px;
  overflow-x: hidden;
}

h1 {
  /* posicion y dimensiones */
  top: 0px;
  left: 0px;
  position: fixed;
  width: 100%;
  height: 60px;
  margin: 0px auto;
  padding: 5px;
  padding-top: 14px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.25);
  /* aspecto visual y contenido*/
  background-color: #F44336;
  color: #ffffff;
  text-align: center;
  font-family: 'Roboto';
  font-size: 26px;
  font-weight: normal;
  z-index: 1;
}

h2,
h3,
h4,
h5,
h6 {
  /*posicion y dimensiones*/
  width: 100%;
  margin: 0px auto;
  margin-top: 30px;
  margin-bottom: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  /* aspecto visual y contenido*/
  color: #333333;
  text-align: justify;
  font: normal 24px "Roboto";
}

h3 {
  font-size: 20px;
}

h4 {
  font-size: 18px;
  text-decoration: underline;
}

h5 {
  font-size: 16px;
  text-decoration: underline;
}

h6 {
  font-size: 14px;
  text-decoration: underline;
}

hr {
  /*posicion y dimensiones*/
  width: 100%;
  margin: 0px auto;
  margin-top: 30px;
  margin-bottom: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

p {
  /*posicion y dimensiones*/
  width: 100%;
  margin: 0px auto;
  margin-top: 10px;
  margin-bottom: 10px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  /* aspecto visual y contenido*/
  color: #333333;
  font: normal 16px "Roboto";
}

form {
  padding: 5px;
  margin: 0px auto;
  margin-top: 2px;
  margin-bottom: 2px;
  width: 100%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  border-style: none;
  background-color: #DDDDDD;
}

form input[type="text"],
[type="password"],
[type="number"],
[type="email"],
[type="date"],
[type="radio"],
[type="checkbox"],
[type="file"],
[type="submit"] {
  padding: 5px;
  margin: 20px 0;
  display: inline-block;
  width: 300px;
  height: 30px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  border: 1px solid #333333;
  text-align: justify;
  font: normal 16px "Roboto";
  color: #333333
}

form input[type="number"] {
  width: 150px;
  cursor: pointer;
}

form input[type="submit"],
[type="reset"],
[type="button"],
form button {
  padding: 5px;
  margin: 20px 0;
  display: inline-block;
  width: 300px;
  height: 30px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  border-style: none;
  text-align: center;
  font: normal 16px "Roboto";
  color: #ffffff;
  background-color: #333333;
  cursor: pointer;
}

form input[type="submit"]:hover,
[type="reset"]:hover,
[type="button"]:hover,
form button:hover {
  background-color: #666666;
}

#mensaje_confirmacion,
#mensaje_alerta,
#mensaje_error {
  padding: 3px 5px 3px 25px;
  margin: 20px auto;
  width: 100%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
 /*imagen antes que el background color*/
  background-color: #aaffaa;
  border: 1px solid #00ff00;
  color: #333333;
  text-align: justify;
  font: bold 16px "Roboto";
}

#mensaje_alerta {
  background-color: #ffffaa;
  border-color: #ffff00;
}

#mensaje_error {
  background-color: #FFAAAA;
  border-color: #FF0000;
}
            
          
!
            
              // creamos las variables necesarias 
var cuenta_usu = 1000;
var cuenta_dest = 1000;

function comprobar() {
  var transaccion = document.formulario.dinero.value;

  if (isNaN(transaccion) || transaccion == "") {
    transaccion = 0.00;
  }

  transaccion = parseFloat(transaccion);
  document.formulario.dinero.value = transaccion;
  console.log(transaccion);
  //imprimir los diferentes mensajes si hay dinero en la cuenta

  if (transaccion > cuenta_usu) {
    $("#movimientos").append("<div id='mensaje_error'>ERROR: Operación no realizada porque se intenta transferir más fondos de los disponibles</div>");
  } else if (transaccion <= 0) {
    $("#movimientos").append("<div id='mensaje_error'>ERROR: Operación no realizada porque se intenta transferir fondos de valor negativo.</div>");
  } else {

    cuenta_usu = cuenta_usu - transaccion;
    cuenta_dest = cuenta_dest + transaccion;

    $("#cuenta_usuario").html("<p><b>Saldo:</b> " + cuenta_usu + "€</p>");
    $("#cuenta_destino").html("<p><b>Saldo:</b> " + cuenta_dest + "€</p>");
    $("#movimientos").append("<div id='mensaje_confirmacion'>Transferencia a favor de ES21 4321 4321 10 9876543210  por un importe de " + transaccion + " €</div>");

    if (cuenta_usu == 0) {
      $("#movimientos").append("<div id='mensaje_alerta'><b>ALERTA:</b> Cuenta vacía </div>");
    } else if (cuenta_usu <= 100) {
      $("#movimientos").append("<div id='mensaje_alerta'><b>ALERTA:</b> Importe en cuenta menor o igual a 100€</div>");
    }
  }

}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console