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
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajeev PunhaniPosted Oct 10, 2016, 11:21 PM
If the above solution is helpful then,accept the answer.
Midhun TpPosted Oct 10, 2016, 12:24 PM
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;
}