I'm making a calculator similar to This Calculator
But instead of using Javascript I'm using only HTML and PHP without any kind of scripting, not even CSS.
What happened is that there are 4 text boxes and depending on the choice from the dropdown menu, every time one of those is left empty because the answer will be output which should be in that textbox but I'm echoing the answer and want to disable the box whose value is not needed at that time.
Any help would be appreciated and I know it's a very lousy code but for the time being I just want to add what I described:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aluminum Pipe - Pressure Rating Calculation </title>
</head>
<body>
<form action="AlPipe.php" method="post">
<div id="new" align="center">
<h2 align="center">Ordering Decimals from Least to Greatest</h2>
<select name="new" align="center">
<option align="center" value="P">Pressure Rating (PR)</option>
<option align="center" value="S">Allowable Stress (S) </option>
<option align="center" value="T">Wall Thickness(T)</option>
<option align="center" value="D">Pipe Outside Diameter(D)</option>
</select>
<p align="center">Allowable Stress(S) =
<input type="text" name="AL" size="5" />
</p>
<p align="center"> Wall Thickness(t) =
<input type="text" name="WT" size="5" />
</p>
<p align="center">Pipe Outside Diameter(D) =
<input type="text" name="POD" size="5"/>
</p>
<p align="center">Pressure Rating(PR) =
<input type="text" name="PR" size="5" />
</p>
<div align="center">
<input type=submit value=Calculate name="Calculate">
<input type=reset value=Reset>
<?php
formula();
function formula()
{
if(isset($_POST['Calculate']))
{
$S=$_POST['AL'];
$T=$_POST['WT'];
$D=$_POST['POD'];
$P=$_POST['PR'];
$cal=$_POST['new'];
}
if($cal=='P')
{
$PR1 = (2 * $S * $T );
$PR2 = $D;
$PR3 = $PR1 / $PR2;
echo "\n Pressure Rating is : ".$PR3;
}
elseif($cal=='S')
{
$S1= ($P * $D) ;
$S2= ($T * 2);
$S3= $S1 / $S2;
echo "\n Allowable Stress is : ".$S3;
}
elseif($cal=='T')
{
$T1 = $P * $D ;
$T2 = 2 * $S;
$T3 = $T1 / $T2;
echo "\nWall Thickness is : ".$T3;
}
elseif($cal=='D')
{
$D1 = 2 * $S * $T / $P ;
echo "\nDiameter is : ".$D1;
}
else
{
echo "Invalid Values";
}
}
?>
</div>
</form>
</div>
</div>
</body>