I am having 1 text field with number of buttons each having value of their own.
In the code below as i have a single input field i have used it to update the value based on button value to the input field id. How can i know the which input field i have selected before the button click to pass the button value to the input field when there are multiple input fields??
var x,y;
function first(){
var y=1;
document.getElementById("how").value=y;
}
function second(){
var x=2;
document.getElementById("how").value=x;
}
<input type="button" onclick="first()" value="1" id="01"/>
<input type="button" onclick="second()" value="2" id="02"/>
<input type="text" value="" id="how"/>
Let me know how this can be achieved in the easiest way
onfocusevent?