Control onClick function
Control onClick function
<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>
这里我放了一些代码,我从参考文献。当我点击数字时,它会在三个地方添加,但我只想在两个地方添加(第三个地方应该是空的)。但是当我点击某个按钮时,相同的按钮值应该存储在以前没有存储的地方。
一个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>
相关文章:
- 直接在函数声明上使用function.prototype.bind
- Javascript onClick and mouseOver function
- Image OnClick to Javascript function
- Javascript get "this" class with onClick function
- 为什么当我尝试在节点中运行函数时,Onclick=“function()” 会显示 404
- on(“click”,function())和onclick=“”之间有什么区别;函数()&”;
- checkbox onclick function in another function
- javascript onclick function null
- onclick =“函数()“;不工作但href="javascript: function()"工
- onclick = "javascript: javascript: function(value);&quo
- 试图通过onclick function()括号传递不同的变量
- JQuery Append Html onclick function
- jquery中的onclick(function(){})和on('click',function(){
- onclick never execute function
- Control onClick function
- 防止onclick-function在settimeout函数中被激活
- 从onclick=function()获取按钮的内容
- OnClick不工作时,我做OnClientClick="function();返回false"
- Javascript 在 onclick 事件中无法识别 self.function
- Javascript function onclick