Been stuck on this for a while now and it is really annoying me. I have a form in HTML that lets the user enter some text, I then created a function in my script to take that text when the user presses submit. The function works fine as it takes the input and stores it in input (i console logged it and it was right). My issue is that i want to take that input and use it outside the function to produce graphs in d3 by filtering using that text that the user input.
I have tried using the code below but it doesn't work, when logging user it says its undefined and hence i cant use it further could some please help.
var user;
function othername(){
var input = document.getElementById("user_name").value;
console.log(input);
user = input;
}
console.log(user)
</script>