how do I pass a variable from one script to another
<p>Here is a script I can't get to work correctly.
It's purpose is to check whether a check box is checked and then to call a second
routine that responds, dependent on what the selectedindex (sindex) was shown to be when I originally called the script</p>

<pre><code>&lt;script type="text/javascript"&gt;
function checkB(ctrl,sindex) {  //get the state of the check box 
var sindex = {
    0: 0,
    1: 1,
    2: 2,
    3: 3
 };


if (ctrl.checked == true) { 
return function( which ) {
replaceContentmainobjectOn(sindex [which]);
} else {    
if (ctrl.checked == false) { 
replaceContentmainobjectOff();
}   
} 
}
&lt;/script&gt;
</code></pre>

<p>here is the second script that is called</p>

<pre><code>var replaceContentmainobjectOn =(function() {
var info = {
    0: 2,
    1: 1,
    2: 2,
    3: 3
 };

    return function( which ) {
    document.getElementById('ecwid-productoption-8840317-mainobject').selectedIndex = ( info[ which ] ) ;
};

}())
</code></pre>

<p>This is what I'm calling the first routine with</p>

<pre><code>onclick="checkB(this,sindex);
</code></pre>
