Using JavaScript to Pass Parameters Between Two ToolBook HTML Applications
One of my most important desires in the last year was how to pass information between two or more ToolBook HTML Applications. Since I have working quite a bit with building a simple solution for an LMS using HTTP Post and ASP, one of the issues was how to keep information such as a username alive as I navigated between a couple of books. I have now found a way since we can call up JavaScript functions within a ToolBook HTML application.
Here is a very simple JavaScript file that gets the job done:
goto.js
function tbfunction_goto(url)
{
window.location.href = url;
}
Note that this function expects a parameter url. The value for this becomes the full link to the second application.
Now, just a short note about passing parameters with URL's. You do this by appending the URL with a ? followed by a Parameter=Value pair.
Example: http://tcc-pub.com/index.html?UserName=tomhall
In this example the word tomhall is the value passed via the UserName parameter.
So, let's see how we put this to use.
This is the Book Properties dialog box for the first book.

Here the goto.js file has been imported and the goto(url) function has been identified.
In the first book, I have written this Actions Editor code:

This book has a global variable URL2: http://tcc-pub.com/tb2004sp2/lesson3/index.html
Notice in the code that I do a query in the first book to collect the UserName. A Set variable action then puts it all together. When done the value for the variable URL2 will be http://tcc-pub.com/tb2004sp2/lesson3/index.html?UserName=UserName
Thus whatever the user has typed as their UserName will be passed as the value for the UserName parameter. The parameter url is set equal to URL2 and the script is executed.

In the second book, all we have to do is this:

Now, anywhere in this book where we need to use the variable UserName, we have it. For instance, we could use this to post information to a record in a Database that corresponds to this user.
Click here to see how it works.