I have 3 files - main.html, one.js and two.js.
Here's a code snippet inside main.html:
<html>
<head>
<head>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
</head>
<body>
<input type="text" id="txtOrigin" name="txtFrom"/>
<input type="text" id="txtDestination" name="txtTo"/>
.....
<button type="submit" id="buttonBusSearch" >Search Bus></button>
</body>
</html>
and inside one.js:
function load()
{
jq("#txtOrigin").val(txtFrom);
jq("#txtDestination").val(txtTo);
jq("#txtOrigin").attr("state", stateFrom);
jq("#txtDestination").attr("state", stateTo);
....
jq("#buttonBusSearch").click();
//need to pass all these val to function test()
}
jq(document).ready(function ()
{
jq("#buttonBusSearch").click(function ()
{
....
}
}
Here is two.js:
function test()
{
console.log(); //to check whether the values has been passed or not
}
I would like to pass txtFrom, txtTo.. values to two.js. Note that these codes were not originally written by me and I need to modify the code inside two.js only. Is there other way to pass these multiple values instead of using global variable? Thanks in advance.