Hướng dẫn calculate total in html - tính tổng trong html
❮ Thẻ HTML Show Thí dụThực hiện tính toán và hiển thị kết quả trong một yếu tố: & nbsp; & nbsp; + & nbsp; = Hãy tự mình thử » Định nghĩa và cách sử dụngThuộc tính Hỗ trợ trình duyệtCác số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Cú phápGiá trị thuộc tính
❮ Thẻ HTML ❮ Tham chiếu chức năng CSS Thí dụThực hiện tính toán và hiển thị kết quả trong một yếu tố: & nbsp; & nbsp; + & nbsp; = Hãy tự mình thử » Định nghĩa và cách sử dụngThuộc tính
Hỗ trợ trình duyệtCác số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính. Thuộc tính
Giá trị
❮ Tham chiếu chức năng CSS Sử dụng calc () để tính toán chiều rộng của một phần tử: #Div1 {& nbsp; Vị trí: Tuyệt đối; & nbsp; Trái: 50px; & nbsp; chiều rộng: calc (100% - 100px); & nbsp; biên giới: 1px màu đen rắn; & nbsp; màu nền: màu vàng; & nbsp; Đệm: 5px; & nbsp; Text-Align: Center;} DOCTYPE html>
<html>
<body>
php
ini_set('display_errors',0);
if( isset( $_REQUEST['calculate'] ))
{
$operator=$_REQUEST['operator'];
$n1 = $_REQUEST['first_value'];
$n2 = $_REQUEST['second_value'];
if($operator=="+")
{
$res= $n1+$n2;
}
if($operator=="-")
{
$res= $n1-$n2;
}
if($operator=="*")
{
$res =$n1*$n2;
}
if($operator=="/")
{
$res= $n1/$n2;
}
if($_REQUEST['first_value']==NULL || $_REQUEST['second_value']==NULL)
{
echo "";
}
}
?>
<form>
<table style="border:groove #00FF99">
<tr>
<td style="background-color:turquoise; color:black; font-family:'Times New Roman'">Enter Numbertd>
<td colspan="1">
<input name="first_value" type="text" style="color:red"/>td>
tr>
<tr>
<td style="color:red; font-family:'Times New Roman'">Select Operatortd>
<td>
<select name="operator" style="width: 63px">
<option>+option>
<option>-option>
<option>*option>
<option>/option>
select>td>
tr>
<tr>
<td style="background-color:turquoise; color:black; font-family:'Times New Roman'">Enter Numbertd>
<td class="auto-style5">
<input name="second_value" type="text" style="color:red"/>td>
tr>
<tr>
<td>td>
<td><input type="submit" name="calculate" value="Calculate" style="color:wheat;background-color:rosybrown" />td>
tr>
<tr>
<td style="background-color:turquoise;color:black">Output = td>
<td style="color:darkblue">php echo $res;?>td>
tr>
table>
form>
body>
html> |