Passing Parameters to a ToolBook Application

One possibility for moving information into a ToolBook HTML application or between two ToolBook HTML applications is to use Parameters.  Sort of "hidden away" in the Actions Editor is a getParameter function.  This function returns the named Parameters from a URL or ToolBook command line.  Parameters should be in the form <name> = <value> pairs separated by spaces.  As an example, you could use this function to get the value of a Parameter named "UserName" and then store it in a global variable named UserName.


Using a Login Page on Website

One example of the use of this is to create a Login on a Website.  Once the learner has logged in, they can be taken to a page that contains a link or links to ToolBook lessons.  Their login information is then passed to that lesson using a simple ASP page.

A form such as that shown below can represent your Login Page.  This is the code for a Login button:

 <form method="POST" action="http://tcc-pub.com/asp/param1.asp">
<p><input type="text" name="UserName" size="20"><input type="submit" value="Login" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

This is the code for the param1.asp page: 

<% 
Dim UserName
response.buffer = true
UserName = request.form("UserName")

If UserName <> "" then

    response.write "<p align=center>" & "<b>" & "Lesson List" & "<p>" & "</b>" & "<hr>"
    response.write "Click the link below to go to the lesson." & "<p>"
    response.write "<a href='http://tccpub.com/tb2004sp2/lesson1/index.html?UserName="& UserName & "'>Start the lesson</a>"

else

    response.write "You must click the Back button and enter your UserName."

end if

%>

Note that the URL is hardcoded with regards to the location of the ToolBook application but is appended with a parameter using the ?  The Parameter Name is UserName and the value for the variable UserName retrieved via the request.form process is set as the value of the Parameter.  Thus the flow of the information is this:

1. The learner types their UserName in the form field.

2. It is posted to the asp as the value for the Parameter UserName.

3. The ASP page gets this information using request.form and transfers it's value to the variable UserName.

4. A response.write process passes this information on to the ToolBook DHTML application as the value for a parameter named UserName.

5. On the ToolBook end, this is transferred back to a variable named UserName and is ready to be used in the application.

You could set up a variety of links to different lessons by adding more response.write lines with the code specific to the location of that application, still passing the same UserName parameter to whatever application (lesson) the learner chooses.

 

Now you try it!

Lessons Login

Please enter your UserName and click the Login button. You will then be taken to a page with a link to a lesson.