<html>
<head>
<style type='text/css'>
span {
text-decoration:underline;
color:blue;
cursor:pointer;
}
</style>
<script>
// show the given page, hide the rest
function show(elementID) {
// try to find the requested page and alert if it's not found
var ele = document.getElementById(elementID);
if (!ele) {
alert("no such element");
return;
}
// get all pages, loop through them and hide them
var pages = document.getElementsByClassName('page');
for(var i = 0; i < pages.length; i++) {
pages[i].style.display = 'none';
}
// then show the requested page
ele.style.display = 'block';
}
function pushButton(buttonValue) {
if (buttonValue == 'C') {
document.getElementById('screen').value = '0';
} else {//this is where most changes occured
var x= document.getElementById('screen').value
x =parseInt(x)+ parseInt(buttonValue);
document.getElementById('screen').value=x;
}
}
function calculate(equation) {
var answer = eval(equation);
document.getElementById('screen').value = answer;
}
function pushButton1(buttonValue) {
if (buttonValue == 'd') {
document.getElementById('quantity').value = '0';
} else {//this is where most changes occured
var x= document.getElementById('quantity').value
x =parseInt(x)+ parseInt(buttonValue);
document.getElementById('quantity').value=x;
}
}
function calculate(equation) {
var answer = eval(equation);
document.getElementById('quantity').value = answer;
}
function pushButton2(buttonValue) {
if (buttonValue == 'd') {
document.getElementById('product').value = '0';
} else {//this is where most changes occured
var x= document.getElementById('product').value
x =parseInt(x)+ parseInt(buttonValue);
document.getElementById('product').value=x;
}
}
function calculate(equation) {
var answer = eval(equation);
document.getElementById('product').value = answer;
}
</script>
</head>
<body>
<table class="calc" cellpadding=5>
<tr>
<td colspan=3><input type="button" class="calc" id="screen" value="0" ></td>
</tr>
<tr>
<td><button type="button" onclick="pushButton(0);pushButton1(0);pushButton2(0);" value="Call2Functions">0</td>
<td><button type="button" onclick="pushButton(1);pushButton1(1);pushButton2(1);" value="Call2Functions">1</td>
<td><button type="button" onclick="pushButton(2);pushButton1(2);pushButton2(2);" value="Call2Functions">2</td>
<td><button type="button" onclick="pushButton(3);pushButton1(3);pushButton2(3);" value="Call2Functions">3</td>
</tr>
</table>
<form name="order" id="order">
<table>
<tr>
<td></td>
<td><input type="text" class="calc" id="product" value="0" ></td>
</tr>
<tr>
<td></td>
<td><input type="text" class="calc" id="quantity" value="0" ></td>
</tr>
</table>
</form>
</body>
</html>
这里我放了一些我从引用中获取的代码。当我点击数字时它会在三个地方添加,但我想只在两个地方添加(第三个地方应该是空的)。但是当我点击某个按钮时,相同的按钮值应该存储在之前没有存储的地方。
答案 0 :(得分:0)
html页面的形式如下:
<html> <!-- Open once -->
<head> <!-- Open once -->
<!-- All style and script here -->
<title></title> <!-- Open once -->
</head>
<body> <!-- Open once -->
<!-- Here your code, your <p>, table or <form> -->
</body>
</html>
表格如下:
<table>
<tr> <!-- First row -->
<td></td> <!-- First column -->
<td></td> <!-- Second column -->
<td></td> <!-- Third column -->
</tr>
<tr> <!-- Second row -->
<td></td> <!-- First column -->
<td></td> <!-- Second column -->
<td></td> <!-- Third column -->
</tr>
</table>
问题是你的代码格式化得很糟糕。例如,您无法在<html>
或<html>
中的<body>
中打开<body>