I want the function to when it is called, will:
- Set up the input element(done)
- Pause the execution until the user presses the enter key
- Set down the input element(done)
- Return the user input from as the function return value
This is for the program is reading a string and executing stuff based on the string sequentially to the string, and I want to change the behavior of the program by prompting the user input at some point. The reading and executing must also stop while the prompt.
The program is completely synchronous.
It is also not a node.js program. It is to be run on a browser and to be able to run offline.
I have an input element.
<input type="text" id="inputElement" readonly>
And I have the function which calls the function which lets the user put value into the element.
function getUserInput(){
var e=document.getElementById("inputElement");
e.value="";
e.readOnly=false;
//TODO:
//pause execution and assign the user input to the variable x
e.readOnly=true;
return x;
}
And a function that calls getUserInput
.
function foo(){
var a=getUserInput();
//do something
}
I have not been able to figure out how to stop the execution of the program while also not crashing it, and also returning the value from the function and not, say just assign it to a variable.