如何从单个输入框中添加,减去,乘以两个数字?
eg:有输入文本框
<input type = "text" id = "id">
我需要使用单个文本框来加、减、乘两个数字。我有单独的加法、减法和乘法按钮。
我尝试过这样的事情:
var te = 0;
var input = false;
    function number(value){
            if(input === false){
                document.getElementById("id").value += value;
            }else{
                document.getElementById("id").value = value;
                input = false;
            }
    };
    
    function calc(opr){
    
        if(opr === '+'){
            te=te+parseInt(document.getElementById("id").value);
            document.getElementById("id").value = te;
            input = true;
            
        }
        
    };
添加工作正常。我需要添加乘法,减法和等于这个。