We've just started to learn Vanilla JS, we had exercise which is creating a calculator by using html, css and js.
I already created the calculator layout (I'll leave the CSS to the end), however I'm getting troubled of input the number that I want into field by using the buttons.
Basically this is my layout so far, but I have some questions about the calculator that I want.
Before I'll show you the layout, here is how I want the calculator looks like by looking at the fields:

So as you can see, in field 1 I want to input the first value, now that we entered the first value, I want to show the math action that I want to do between the 2 values, in field 3 I want to input the second value, after I inputted the value, I'll press on the equal button, the the last field will show me the result..
As I said before, I already created the layout for both fields and buttons, here is the layout:
<div class="calculator">
<input type="text" class="calculator-screen" value="1" disabled /> <!--value 1-->
<input type="text" class="calculator-screen" value="math action" disabled /> <!--math action-->
<input type="text" class="calculator-screen" value="2" disabled /> <!--value 2-->
<button type="button" class="equal-sign" value="=" onclick="solve()">=</button>
<input type="text" class="result" value="result" disabled />
<div class="calculator-keys">
<button type="button" class="operator" value="+" onclick="dis('+')">+</button>
<button type="button" class="operator" value="-" onclick="dis('-')">-</button>
<button type="button" class="operator" value="*" onclick="dis('*')">*</button>
<button type="button" class="operator" value="/" onclick="dis('/')">/</button> <br>
<button type="button" value="7" onclick="dis('7')">7</button>
<button type="button" value="8" onclick="dis('8')">8</button>
<button type="button" value="9" onclick="dis('8')">9</button><br>
<button type="button" value="4" onclick="dis('4')">4</button>
<button type="button" value="5" onclick="dis('5')">5</button>
<button type="button" value="6" onclick="dis('6')">6</button><br>
<button type="button" value="1" onclick="dis('1')">1</button>
<button type="button" value="2" onclick="dis('2')">2</button>
<button type="button" value="3" onclick="dis('3')">3</button><br>
<button type="button" value="0" onclick="dis('0')">0</button>
<button type="button" class="decimal" value="." onclick="dis('.')">.</button>
<button type="button" class="all-clear" value="all-clear" onclick="clr()">AC</button>
</div>
and my js code so far:
function dis(val)
{
document.getElementById("result").value+=val
}
//function that clear the display
function clr()
{
document.getElementById("result").value = ""
}
So after I did the layout and the buttons how do I make it that I'll be able to input the values by using the buttons?
in addition to that, how to I show the math action (- * / +) between the values field?
resultinput have a class namedresultbut you search it by id.. give to the inputid="result"