Yes, It is possible to insert the value in the input box and result in another text box. You can use the HTML form and a PHP script to find out the area of the rectangle on the button click. First of all, you need to know the mathematical formula for the area of the rectangle. The mathematic formula for the area of the rectangle is A = wl.
A = A denotes the area of the rectangle.
w= w denotes the width of the rectangle.
l = l is the length of the rectangle.
We can write this formula in PHP. like = a=w*l ;
You can see the w and l will be entered by the user. We create three text boxes in HTML. The two text boxes are for l and w and one text box for the result.
When a user enters the l and w of the rectangle, the result is displayed in the third text box.
Let's create an HTML form.
<html>
<body>
<form action="" method="post">
Width :
<input type="text" name="w"><br>
Length :
<input type="text" name="l"><br>
<input type="submit" name="submit" value="area"><br>
</form>
</body>
</html>
We created an HTML form with two input boxes and one button. Now create the PHP script to get the area of the rectangle in the third text box.
<?php
$a="";
if(isset($_POST['submit']))
{
$w=$_POST['w'];
$l=$_POST['l'];
$a=$w*$l;
}
?>
Result:<input type="text" value="<?php echo $a; ?>">
Now add this PHP code in a single file and execute.
<html>
<body>
<form action="" method="post">
Width :
<input type="text" name="w"><br>
Length :
<input type="text" name="l"><br>
<input type="submit" name="submit" value="area"><br>
</form>
</body>
</html>
<?php
$a="";
if(isset($_POST['submit']))
{
$w=$_POST['w'];
$l=$_POST['l'];
$a=$w*$l;
}
?>
Result:<input type="text" value="<?php echo $a;?>">
Enter the width and length of the rectangle in text boxes, you will get the result into the third text box.