juan_86_86
Bovino maduro
- Desde
- 24 Feb 2007
- Mensajes
- 340
- Tema Autor
- #1
Como me lo pidieron una calculadora en php aki la dejo espero que les sirva saludos bakunos
:mota::mota::mota::mota:

<!DOCTYPE html PUBLIC "~//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<html xmlns:"http://www.w3.org/1999/xhtml">
<head>
<title>Juan Carlos Guardado</title>
<script language="JavaScript">
function EsValido()
{
var OperandoA = document.getElementById('idOperandoA').value;
if(isNaN(OperandoA) || /^\s+$/.test(OperandoA) || OperandoA.length == 0)
{
alert('Debe escribir un valor numerico para el Openrando A');
document.getElementById('idOperandoA').value='';
document.getElementById('idOperandoA').focus();
return false;
}
var OperandoB = document.getElementById('idOperandoB').value;
if(isNaN(OperandoB) || /^\s+$/.test(OperandoB) || OperandoB.length == 0)
{
alert('Debe escribir un valor numerico para el Openrando B');
document.getElementById('idOperandoB').value='';
document.getElementById('idOperandoB').focus();
return false;
}
}
</script>
</head>
<body>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>" onsubmit="return EsValido();">
<fieldset style="padding:25px;">
<legend style="padding:5px;background-color:yellow;font-weight:bold;">
Operaciones Aritméticas
</legend>
<table>
<tr>
<td>
<label for = "idOperando1">Operando A</label>
</td>
<td>
<input type="text" name="OperandoA" id="idOperandoA" size="10" maxlength="8"/>
</td>
</tr>
<tr>
<td>
<label for = "idOperando2">Operando B</label>
</td>
<td>
<input type="text" name="OperandoB" id="idOperandoB" size="10" maxlength="8"/>
</td>
</tr>
</table>
<br/><br/>
<input type="submit" name="Suma" value="Sumar"/>
<input type="submit" name="Resta" value="Restar"/>
<input type="submit" name="Producto" value="Multiplicar"/>
<input type="submit" name="Cociente" value="Dividir"/>
<input type="submit" name="Modulo" value="Módulo"/>
</fieldset>
</form>
<?php
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Suma"]))
{
echo"La Operacion $_POST[OperandoA]+ $_POST[OperandoB] es igual a ".($_POST["OperandoA"] + $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Resta"]))
{echo"La Operacion $_POST[OperandoA]- $_POST[OperandoB] es igual a ".($_POST["OperandoA"] - $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Producto"]))
{echo"La Operacion $_POST[OperandoA] x $_POST[OperandoB] es igual a ".($_POST["OperandoA"] * $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Cociente"]))
{echo"La Operacion $_POST[OperandoA] ÷ $_POST[OperandoB] es igual a ".@($_POST["OperandoA"] / $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Modulo"]))
{echo"La Operacion $_POST[OperandoA] MOD $_POST[OperandoB] es igual a ".($_POST["OperandoA"] % $_POST["OperandoB"]);
}
?>
</body>
</html>
:mota::mota::mota::mota:


<!DOCTYPE html PUBLIC "~//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<html xmlns:"http://www.w3.org/1999/xhtml">
<head>
<title>Juan Carlos Guardado</title>
<script language="JavaScript">
function EsValido()
{
var OperandoA = document.getElementById('idOperandoA').value;
if(isNaN(OperandoA) || /^\s+$/.test(OperandoA) || OperandoA.length == 0)
{
alert('Debe escribir un valor numerico para el Openrando A');
document.getElementById('idOperandoA').value='';
document.getElementById('idOperandoA').focus();
return false;
}
var OperandoB = document.getElementById('idOperandoB').value;
if(isNaN(OperandoB) || /^\s+$/.test(OperandoB) || OperandoB.length == 0)
{
alert('Debe escribir un valor numerico para el Openrando B');
document.getElementById('idOperandoB').value='';
document.getElementById('idOperandoB').focus();
return false;
}
}
</script>
</head>
<body>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>" onsubmit="return EsValido();">
<fieldset style="padding:25px;">
<legend style="padding:5px;background-color:yellow;font-weight:bold;">
Operaciones Aritméticas
</legend>
<table>
<tr>
<td>
<label for = "idOperando1">Operando A</label>
</td>
<td>
<input type="text" name="OperandoA" id="idOperandoA" size="10" maxlength="8"/>
</td>
</tr>
<tr>
<td>
<label for = "idOperando2">Operando B</label>
</td>
<td>
<input type="text" name="OperandoB" id="idOperandoB" size="10" maxlength="8"/>
</td>
</tr>
</table>
<br/><br/>
<input type="submit" name="Suma" value="Sumar"/>
<input type="submit" name="Resta" value="Restar"/>
<input type="submit" name="Producto" value="Multiplicar"/>
<input type="submit" name="Cociente" value="Dividir"/>
<input type="submit" name="Modulo" value="Módulo"/>
</fieldset>
</form>
<?php
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Suma"]))
{
echo"La Operacion $_POST[OperandoA]+ $_POST[OperandoB] es igual a ".($_POST["OperandoA"] + $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Resta"]))
{echo"La Operacion $_POST[OperandoA]- $_POST[OperandoB] es igual a ".($_POST["OperandoA"] - $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Producto"]))
{echo"La Operacion $_POST[OperandoA] x $_POST[OperandoB] es igual a ".($_POST["OperandoA"] * $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Cociente"]))
{echo"La Operacion $_POST[OperandoA] ÷ $_POST[OperandoB] es igual a ".@($_POST["OperandoA"] / $_POST["OperandoB"]);
}
if(isset($_POST["OperandoA"], $_POST["OperandoA"], $_POST["Modulo"]))
{echo"La Operacion $_POST[OperandoA] MOD $_POST[OperandoB] es igual a ".($_POST["OperandoA"] % $_POST["OperandoB"]);
}
?>
</body>
</html>