Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于每个JavaScript计算器的错误逻辑的建议_Javascript_Html - Fatal编程技术网

关于每个JavaScript计算器的错误逻辑的建议

关于每个JavaScript计算器的错误逻辑的建议,javascript,html,Javascript,Html,如何改进构建计算器的逻辑?我不知道如何正确地集成sin/cos/tan/percents。这是我第一次真正的java脚本任务,我不知道如何处理我遇到的所有错误。结果我经常得不到一个数字。我知道我无法将所有内容读入变量来处理计算。但我不知道接下来该怎么办 函数in1(){ document.calc.txt.value+=“1” } 函数in2(){ document.calc.txt.value+=“2” } 函数in3(){ document.calc.txt.value+=“3” } 函数

如何改进构建计算器的逻辑?我不知道如何正确地集成sin/cos/tan/percents。这是我第一次真正的java脚本任务,我不知道如何处理我遇到的所有错误。结果我经常得不到一个数字。我知道我无法将所有内容读入变量来处理计算。但我不知道接下来该怎么办

函数in1(){
document.calc.txt.value+=“1”
}
函数in2(){
document.calc.txt.value+=“2”
}
函数in3(){
document.calc.txt.value+=“3”
}
函数in4(){
document.calc.txt.value+=“4”
}
函数in5(){
document.calc.txt.value+=“5”
}
函数in6(){
document.calc.txt.value+=“6”
}
函数in7(){
document.calc.txt.value+=“7”
}
函数in8(){
document.calc.txt.value+=“8”
}
函数in9(){
document.calc.txt.value+=“9”
}
函数inAdd(){
document.calc.txt.value++='+'
}
函数inSub(){
document.calc.txt.value+='-'
}
函数inMult(){
document.calc.txt.value+='*'
}
函数inDiv(){
document.calc.txt.value+='/'
}
函数索引(){
document.calc.txt.value+='。'
}
flag=0;
函数inSin(){
document.calc.txt.value+='Sin'
标志=1
}
函数inCos(){
document.calc.txt.value+='Cos('
标志=2
}
函数inTan(){
document.calc.txt.value+='Tan'
标志=3
}
函数inPercent(){
document.calc.txt.value=calc.txt.value/100;
}
var inputTest=document.getElementById(“”)值;
函数等于(){
如果(标志==1){
var输入=calc.txt.value;
var newNumber=输入子字符串(4);
document.calc.txt.value=Math.sin(newNumber);
标志=0
}
如果(标志==2){
var输入=calc.txt.value;
var newNumber=输入子字符串(4);
document.calc.txt.value=Math.cos(newNumber);
标志=0
}
如果(标志==3){
var输入=calc.txt.value;
var newNumber=输入子字符串(4);
document.calc.txt.value=Math.tan(newNumber);
标志=0
}else if(标志==0){
document.calc.txt.value=(eval(calc.txt.value))
}
}
.flexBoxContainer{
显示器:flex;
证明内容:周围的空间;
调整项目:灵活启动;
}
.头衔{
边框:黑色5px实心;
颜色:红色;
填充:2px;
字号:21 ;;
宽度:310px;
文本对齐:居中;
}
.计算器{
显示器:flex;
柔性包装:包装;
证明内容:中心;
对齐内容:居中对齐;
框大小:边框框;
}
.计算器.钥匙{
边框:白色3倍脊;
高度:60px;
宽度:75px;
}
.输入框{
边框:白色3倍脊;
高度:60px;
宽度:236px;
弹性基准:66%;
}
.输入显示{
边框:黑色3px实心;
背景色:白色;
高度:45px;
宽度:233x;
弹性基准:66%;
文本对齐:右对齐;
}
.中心{
显示器:flex;
弯曲方向:立柱;
证明内容:中心;
;
}
.集装箱1{
显示器:flex;
柔性包装:包装;
证明内容:中心;
对齐内容:居中对齐;
}
@介质(最小宽度:381px){
.计算器{
宽度:380px;
}
}
/*下面的按钮格式*/
.按钮1{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px19px;
文本对齐:居中;
显示:内联块;
字体大小:36px;
光标:指针;
}
.按钮2{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px20px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
巴顿菌素{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px7px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
buttonCos先生{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充物:1px 3px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
布顿坦先生{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充物:1px2px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
.按钮3{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px17px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
.钮扣分钟{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px22px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
巴顿迪夫先生{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px21px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
B.buttonDec{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px23px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}
buttonPer先生{
边框:黑色10px固体;
颜色:白色;
背景颜色:蓝色;
填充:1px12px;
文本对齐:居中;
显示:内联块;
字体大小:30px;
光标:指针;
}

JavaScript计算器赋值
JavaScript计算器
C
1.
2.
3.
罪
4.
5.
6.
科斯
7.
8.
9
棕褐色的
+
-
*
/
.
0
= 
%

这一行是用来做什么的:
var inputTest=document.getElementById(“”)value;
计算器的问题在这个网站上经常出现,看看:这一行是用来做什么的:
var inputTest=document.getElementById(“”)value;
计算器的问题在这个网站上经常出现,看看: