I have a file named one.js and another file named two.js. There is a function named current() in one.js that returns a string that I would like to pass to two.js.
current():
function current()
{
if(selection === 0 && yesResources[questionsCounter] != null)
{
return yesResources[questionsCounter];
}
else if(selection === 1 && noResources[questionsCounter] != null)
{
return noResources[questionsCounter];
}
else
{
return 'You are on the right track!';
}
}
In an HTML file, I have the following script tags called:
<script type='text/javascript' src='one.js'></script>
<script type='text/javascript' src='two.js'></script>
In the HTML file, I've also written code with the purpose of changing the content of a modal box after a button click with the result of current(). The code is as follows:
<!-- Trigger/Open The Modal -->
<button id="myBtn">Resources</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Resources</h2>
</div>
<div class="modal-body">
<p>Test</p>
<p id='modalContent'>current()</p>
</div>
<div class="modal-footer">
<h3>Living Progress</h3>
</div>
</div>
</div>
The string that gets returned by current() is not displaying in the modal. Am I misunderstanding how to bring in a value from one JS to another?