Javascript Java脚本数学方程
我的javascript代码不起作用,因为单击按钮时没有显示任何内容。有人知道解决办法吗?我已经试着取出代码并将按钮格式化为Javascript Java脚本数学方程,javascript,math,button,Javascript,Math,Button,我的javascript代码不起作用,因为单击按钮时没有显示任何内容。有人知道解决办法吗?我已经试着取出代码并将按钮格式化为alert(…),结果成功了,所以现在我被困在数学方程中。我肯定我没有漏掉一个括号或标点符号。感谢您的反馈和帮助 <!DOCTYPE html> <html> <head> <title>Project</title> <style type="text"/css&g
alert(…)
,结果成功了,所以现在我被困在数学方程中。我肯定我没有漏掉一个括号或标点符号。感谢您的反馈和帮助
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<style type="text"/css>
.inbox
{
width=30px;
text-align: right;
border: 2px solid black;
}
.align
{
text-align: right
}
</style>
<script type="text/javascript">
function compute() {
var a = form1.inputA.value;
a = parseFloat(a);
var b = form1.inputB.value;
b = parseFloat(b);
var c = form1.inputC.value;
c = parseFloat(c);
var e = a * 5.49;
form1.sumA.value = e.toFixed(2);
}
function pageInit()
{
form1.inputA.focus();
}
</script>
</head>
<body onload="pageInit();">
<form id="form1">
<table border="2" >
<tr>
<th colspan="4">Sample Order Form</th>
</tr>
<tr>
<th>Quantity</th>
<th>item</th>
<th>Unit Price</th>
<th>Totals</th>
</tr>
<tr>
<th>
<input tabindex="1" class="inbox" type="text" id="inputA" />
</th>
<th>Apples</th>
<td>$5.49</td>
<th>
<input class="inbox" type="text" id="sumA" readonly="readonly" />
</th>
</tr>
<tr>
<th>
<input tabindex="4" type="button" value="Compute" onclick="compute();" />
</th>
</tr>
</table>
</form>
</body>
</html>
项目
收件箱
{
宽度=30px;
文本对齐:右对齐;
边框:2件纯黑;
}
排列
{
文本对齐:右对齐
}
函数compute(){
var a=form1.inputA.value;
a=浮点数(a);
var b=form1.inputB.value;
b=浮点数(b);
var c=form1.inputC.value;
c=浮点数(c);
var e=a*5.49;
表1.sumA.value=e.toFixed(2);
}
函数pageInit()
{
form1.inputA.focus();
}
订购表格样本
量
项目
单价
总数
苹果
$5.49
试试这个
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<style>
.inbox {
width =30px;
text-align: right;
border: 2px solid black;
}
.align {
text-align: right;
}
</style>
<script type="text/javascript">
function compute() {
var a = document.getElementById("inputA").value;
var e = a * 5.49;
document.getElementById("sumA").value = e.toFixed(2);
}
function pageInit() {
document.getElementById("inputA").focus();
}
</script>
</head>
<body onload="pageInit();">
<form id="form1">
<table border="2">
<tr>
<th colspan="4">Sample Order Form</th>
</tr>
<tr>
<th>Quantity</th>
<th>item</th>
<th>Unit Price</th>
<th>Totals</th>
</tr>
<tr>
<th>
<input tabindex="1" class="inbox" type="text" id="inputA" />
</th>
<th>Apples</th>
<td>$5.49</td>
<th>
<input class="inbox" type="text" id="sumA" readonly="readonly" />
</th>
</tr>
<tr>
<th>
<input tabindex="4" type="button" value="Compute" onclick="compute();" />
</th>
</tr>
</table>
</form>
</body>
</html>
项目
.收件箱{
宽度=30px;
文本对齐:右对齐;
边框:2件纯黑;
}
.对齐{
文本对齐:右对齐;
}
函数compute(){
var a=document.getElementById(“inputA”).value;
var e=a*5.49;
document.getElementById(“sumA”).value=e.toFixed(2);
}
函数pageInit(){
document.getElementById(“inputA”).focus();
}
订购表格样本
量
项目
单价
总数
苹果
$5.49
那么是java还是javascript?您应该重新设置问题的格式,以获取表单元素。表格1尚未草签。