如何在不使用 JavaScript 的情况下将该程序转换为仅包含计算的 php?我正在使用回声“”;我应该使用 If 计算($choice)
<html>
<head><title>hw4-5</title>
<style type='text/css'>
table{color:black;background-color:lightgray;border:6px solid black;border-width:4px;}
th{color:white;background-color:black;outline-style:solid;outline-width:2px;border:2px solid black;}
input.button{color:black;background-color:red;border:4px solid black;}
input#idname1,input#idname2,input#idname3{background-color:DEDEE6;border:4px solid black;}
</style>
<script type='text/javascript'>
function compute(choice)
{
var tbox1=document.getElementById('idname1');
var tbox2=document.getElementById('idname2');
var tbox3=document.getElementById('idname3');
if(choice==1){tbox2.value=parseInt(tbox1.value)*(tbox1.value);}
else if(choice==2){tbox3.value=parseInt(tbox1.value)*4;}
else if(choice==3){tbox2.value=parseInt(tbox1.value)*(tbox1.value);
tbox3.value=parseInt(tbox1.value)*4;}
else{tbox1.value=tbox2.value=tbox3.value='';}
}
</script>
</head>
<form>
<table>
<th colspan='2' >SQUARE PROBLEM</th>
<tr><td><label>Side: </label></td><td><input type='text' id='idname1' /></td></tr>
<tr><td><label>Area: </label></td><td><input type='text' id='idname2' /></td></tr>
<tr><td><label>Perimeter:</label></td><td><input type='text' id='idname3' /></td></tr>
<tr><td colspan='2' >
<input class='button' type='button' value='Area' onClick='compute(1)' />
<input class='button' type='button' value='Perimeter' onClick='compute(2)' />
<input class='button' type='button' value='Both' onClick='compute(3)' />
<input class='button' type='button' value='Clear' onClick='compute(4)' /></td></tr>
</table>
</form>
</html>