I’m trying to build a calculator and I want to get the values of the clicked buttons in the textbox
this just an example how can I get the values of the clicked buttons here
<input type="text" name="" id="textfield" placeholder="Text" class="Text" readonly><br>
<button class="Y" value="Y" onclick="">Y</button>
<button class="A" value ="A" onclick="">A</button>
<button class="S" value ="S" onclick="">S</button>
<button class="I" value ="I" onclick="">I</button>
<button class="R" value ="R" onclick="">R</button>
2
Answers
Here you can use javascript to handle this type of functionality . For Example :
You don’t have to set value in button. Check this JSFiddle
Anyway, here’s snippet for approach with button’s value: