"Calculator"
Bootstrap 3.0.0 Snippet by Emiliano87

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>Calculadora Física</title> <link rel="shortcut icon" href="../favicon.ico"> <link rel="stylesheet" type="text/css" href="css/default.css" /> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css'> <link rel="stylesheet" type="text/css" href="css/component.css" /> <script type="text/javascript" src="js/formcalculations.js"></script> </head> <script type="text/javascript"> function valida(e){ tecla = (document.all) ? e.keyCode : e.which; //Tecla de retroceso para borrar, siempre la permite if (tecla==8){ return true; } // Patron de entrada, en este caso solo acepta numeros patron =/[0-9]/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); } function Checkradiobutton() { if(document.getElementById('r1').checked ){ document.getElementById('box1').disabled=true; document.getElementById('box2').disabled=false; document.getElementById('box3').disabled=false; document.getElementById('box5').disabled=false; }else if (document.getElementById('r2').checked ){ document.getElementById('box1').disabled=false; document.getElementById('box2').disabled=true; document.getElementById('box3').disabled=false; document.getElementById('box5').disabled=false; }else if (document.getElementById('r3').checked ){ document.getElementById('box1').disabled=false; document.getElementById('box2').disabled=false; document.getElementById('box3').disabled=true; document.getElementById('box5').disabled=false; }else if (document.getElementById('r4').checked ){ document.getElementById('box1').disabled=false; document.getElementById('box2').disabled=false; document.getElementById('box3').disabled=false; document.getElementById('box5').disabled=true; } } </script> <body> <div id="wrap"> <form action="" id="cakeform" onsubmit="return false;"> <div> <div class="top"> <div class="cont_details"> <div class="row"> </div> </div> </div> <div class="cont_details"> <fieldset> <legend>Trabajo de un gas - Resolver según lo solicitado</legend> <tr><font face="Bedrock" color="green" style="font-weight: bold;" size="2"> <input type="radio" name="position" id="r1" value="a" onclick="Checkradiobutton();clean();" checked/>Presión <input type="radio" name="position" id="r3" value="c" onclick="Checkradiobutton();clean();"/>Moles <input type="radio" name="position" id="r2" value="b" onclick="Checkradiobutton();clean();"/>Volumen <input type="radio" name="position" id="r4" value="d" onclick="Checkradiobutton();clean();"/>Temperatura </font> <td><label for='Presión'>Presión</label><input id="box1" type="text" onkeypress="return valida(event)" title="La presión debe ser expresada en Atm." disabled/></td> <td><label for='Volumen'>Volumen</label><input id="box2" type="text" onkeypress="return valida(event)" title="El volúmen debe estar ser expresado en Litros." /></td> <td><label for='Moles'>Moles de Gases</label><input id="box3" type="text" onkeypress="return valida(event)" title="Los moles de gases debe ser expresado en moles." /></td> <td><label for='Constante'>Constante universal de los gases ideales</label><td><input id="box4" disabled placeholder="0.082" title="La constante universal es 0.082 (Litros x Atm )/ (mol x Kelvin)"/></td> <td><label for='Temperatura'>Temperatura (En ºC)</label><input id="box5" type="text" onkeypress="return valida(event)" title="La temperatura se expresa en Kelvin = ºC + 273.16" /></td> <td><label for='Resultado'>Resultado</label><td><input id="result" disabled /></td> <td><label for='Resultado'></label><td></td> <button class="btn btn-7 btn-7c btn-icon-only icon-arrow-right" onclick="calculate();">Resultado</button> <button class="btn btn-7 btn-7d btn-icon-only icon-remove" onclick="clean();">Empty</button> </tr> </fieldset> </div> </div> </form> <a href="calculadoraCalorimetria.html" class="button hot"></a> <a href="graficador.html" class="button graph"></a> </div><!--End of wrap--> </body> </html>
body { color: white; display: flex; justify-content: center; align-items: center; background: white; backface-visibility: hidden; } input[type="radio"] { appearance: none; margin: 0 40px; width: 24px; height: 24px; background: #eeeeee; box-shadow: inset 0 0 0 .4em white, 0 0 0 .3em; border-radius: 50%; transition: .2s; cursor: pointer; color: #363945; } input[type="radio"]:hover, input[type="radio"]:checked { background: #363945; box-shadow: inset 0 0 0 .6em white, 0 0 0 .3em; } input[type="radio"]:checked { background: #56be8e; box-shadow: inset 0 0 0 .4em white, 0 0 0 .3em #56be8e; } input[type="radio"]:focus { outline: 0; } #wrap{ width:750px; margin:0 auto; text-align:center; margin-top:8px; padding:5px; background:#fff; font-family:AvenirLTStd, Arial, Helvetica, sans-serif; font-size:13px; line-height:16px; } #wrap .cont_details fieldset,.cont_order fieldset{ margin:10px; padding:20px; -moz-border-radius: 10px; -webkit-border-radius: 10px; -khtml-border-radius: 10px; border-radius: 10px; } #wrap legend{ font-size:16px; font-family:Georgia, "Times New Roman", Times, serif; color:#000; font-weight:bold; font-style:italic; padding-bottom:10px; } #wrap .cont_details input{ margin-bottom:10px; color:#000; } #wrap .input1:hover,.input1:active{ } #wrap label{ display:block; font-size:12px; color:#000; font-weight:bold; } #wrap label.inlinelabel { display:inline; } #wrap .cont_order input{ margin-bottom:5px; } #wrap .cont_order p{ padding-top:5px; } #wrap input[type="radio"] { margin-top:8px; margin-bottom:8px; } #wrap input[type="text"]:hover, #wrap input[type="text"]:active { background-color: #FAF398; } #wrap input#submit { margin:10px; padding-left:20px; padding-right:20px; padding-top:10px; padding-bottom:10px; } #wrap div#totalPrice { padding:10px; font-weight:bold; background-color:#ff0; } #wrap label.radiolabel { font-weight:normal; display:inline; } .help-tip{ position: absolute; top: 18px; right: 18px; text-align: center; background-color: #BCDBEA; border-radius: 50%; width: 24px; height: 24px; font-size: 14px; line-height: 26px; cursor: default; } .help-tip:before{ content:'?'; font-weight: bold; color:#fff; } .help-tip:hover p{ display:block; transform-origin: 100% 0%; -webkit-animation: fadeIn 0.3s ease-in-out; animation: fadeIn 0.3s ease-in-out; } .help-tip p{ /* The tooltip */ display: none; text-align: left; background-color: #1E2021; padding: 20px; width: 300px; position: absolute; border-radius: 3px; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2); right: -4px; color: #FFF; font-size: 13px; line-height: 1.4; } .help-tip p:before{ /* The pointer of the tooltip */ position: absolute; content: ''; width:0; height: 0; border:6px solid transparent; border-bottom-color:#1E2021; right:10px; top:-12px; } .help-tip p:after{ /* Prevents the tooltip from being hidden */ width:100%; height:40px; content:''; position: absolute; top:-40px; left:0; } /* CSS animation */ @-webkit-keyframes fadeIn { 0% { opacity:0; transform: scale(0.6); } 100% { opacity:100%; transform: scale(1); } } @keyframes fadeIn { 0% { opacity:0; } 100% { opacity:100%; } }
function calculate() { var myBox1 = document.getElementById('box1').value; var myBox2 = document.getElementById('box2').value; var myBox3 = document.getElementById('box3').value; var myBox4 = document.getElementById('box4').placeholder; var myBox5 = document.getElementById('box5').value; var result = document.getElementById('result'); var myResult = 0; //Calcula los moles if(!myBox1.match(/\S/) && !myBox2.match(/\S/) && !myBox3.match(/\S/) && !myBox5.match(/\S/) ){ alert("Existe algun campo incompleto"); } if(myBox1.value!='' && myBox2.value!='' && !myBox3.match(/\S/) && myBox5.value!='' ){ myResult = (myBox1 * myBox2)/(myBox4 * (parseInt(myBox5)+parseInt(273.16))); } //Calcula la presión else if(!myBox1.match(/\S/) && myBox2.value!='' && myBox3.value!='' && myBox5.value!='' ){ myResult = ((myBox3 * myBox4 * (parseInt(myBox5)+parseInt(273.16)))/myBox2); } //Calcula la temperatura else if(myBox1.value!='' && myBox2.value!='' && myBox3.value!=''&& !myBox5.match(/\S/)){ myResult = (myBox1 * myBox2)/(myBox3 * myBox4); } //Calcula el volumen else if(myBox1.value!='' && !myBox2.match(/\S/) && myBox3.value!=''&& myBox5.value!='' ){ myResult = ((myBox3 * myBox4 * (parseInt(myBox5)+parseInt(273.16)))/myBox1); } result.value = myResult; /*if (myBox1 == 0 && myBox2 ==0){ result.value=''; }else{ result.value = myResult; }*/ } function clean() { document.getElementById("box1").value = ""; document.getElementById("box2").value = ""; document.getElementById("box3").value = ""; document.getElementById("box5").value = ""; document.getElementById("result").value = ""; }

Related: See More


Questions / Comments: