Question about javascript
how to get a button value on a textbox using javascript.e.g. if i press button 5 then 5 should print on textbox.basically i wonna make acalculator using javascript
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Midhun TpRank #388 · 6.5K reputationPosted Oct 10, 2016, 8:24 AM EDT
Try below code- document.getElementById("textboxid").value=document.getElementById("buttonid").value;
If you want dynamic button values, then you can call an onclick function on button and pass value to function.
input type="submit" id="btn" value="5" onclick="myfunction(this.value)"
function myfunction(val){
document.getElementById("textboxid").value=val;
}
Rajeev PunhaniRank #551 · 4.4K reputationPosted Oct 10, 2016, 7:21 PM EDT
If the above solution is helpful then,accept the answer.