How to use JavaScript to Configure and Control the Simulation
The initial conditions of the simulation can be setup by using parameters in the <applet> tag:
<param name="c" value="10">
<param name="dt" value="0.1">
<param name="T" value="1.5">
<param name="v" value="0.4">
If you decide not to use such paramater tags, the default values are applied to the parameters. In addition to using parameter tags, you can use JavaScript methods to configure and control the simulation. This is the more powerful and flexible way and explained in the following:
1. Using buttons and Hyperlinks to control the simulation:
2. Using JavaScript methods to create your own methods:
function initialize() {
simulation.jsSetV(0.3);
simulation.jsSetT(1);
simulation.jsSetC(10);
simulation.jsSetDt(0.1);
}
Note: Setting the initial conditions of the simulation by using JavaScript overrides existing parameter tags inside the applet tag.
3. Creating your own exercises and problems:
In order to create your own exercise or problem, write your own function using the JavaScript methods provided by the simulation and launch it on the loading of the embedding web page. In order to do this, include the onload="JavaScript:initialize();" (or the name of any other function you have created and want to execute on loading of the page) parameter in the <body> tag of the embedding web page. You can find an example exercise in the exercise.html file.