I want to use global variable number = 2, but when in input form something is put I want to change value of global variable because I'm going to use it in another function so at the beginning I want number = 2 but when other value is put in input form I want number to take that value.
<form onsubmit="return timed('commands')">
<input type="number" name="a" id="commands"><br>
</form>
var number= 2;
function timed(id)
{
number=getElementById(id).value;
return false;
}
You can add the event onchange to handle this:
<form onsubmit="return timed('commands')">
<input type="number" name="a" id="commands" onchange="changeNumber(this.value)"/><br>
</form>
And add the function in the area:
function changeNumber(value){
number=value
}