How to organize the job functions, depending on changes to the global variable?

Hello, when loading the page I have popup window with 2 radio inputname (for example, select the type of registration). After any choice, the window hides and runs further code. How to make selection of a radio button affects the execution of subsequent functions can be written to the global variable value and check before executing other functions? For example, when selection of the second input, I have created the array, which changes the work functions and I will need to pass and change it in the future, but if not, then execute the old code.
March 19th 20 at 08:57
1 answer
March 19th 20 at 08:59
Just record into a variable. Something like this:

let inputValue = ";

// then on the onchange of the input record to a variable
const inputElement = document.querySelector('.radio-input');
inputElement.addEventListener('change', function() {
 inputValue = this.value;

// further code will take the value of the circuit
const someFunction = () => {
just let inputValue not const - eldon commented on March 19th 20 at 09:02 something isn't working. Strongly do not swear, I'm a beginner, but I think that someFunction is not transmitted inputValue = this.value; because the loading of the document has already passed the empty inputValue. Or am I wrong? - janessa_Sporer commented on March 19th 20 at 09:05
@janessa_Sporer are roughly as follows: functions are not performed by themselves. They need to call. That is, when original document is loaded, all functions are defined, but not enforced. That is, in order to obtain the value of the variable inputValue. You need to call the function someFunction.
Something like this: change the values in the radio buttons and press the button. - Helene.Jaco commented on March 19th 20 at 09:08
@Helene.Jaco, thanks, already got all the way there. - janessa_Sporer commented on March 19th 20 at 09:11

Find more questions by tags JavaScript