I'm doing some basic graphing of data using Chartjs combined with an ajax call to a third-party database.
When the user searches for an item and triggers that search by a button click, a default graph is automatically generated on the new page. I'd like the user to be able to customize the graph (i.e. change it from a line to a mountain or the time interval).
I've created all my buttons on the html and all my ajax calls and tested them. They all work. What is not working is the search term.
The value of the term searched is saved in the initial search button click, but each modification to the graph (and their corresponding button clicks) are not INSIDE the default button click, but outside it, so they do not have access to the value of the search term variable.
I thought it was bad coding practice to have nested button clicks, but I'm not sure how I'd get the value of the search term otherwise.
$('#searchBTN').on('click', function(){
event.preventDefault();
// get user input
var searchTerm = $('#searchInput').val();
$('#searchInput').val('');
