Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:25:30+00:00 2026-05-31T16:25:30+00:00

Here is a script I can’t get to work correctly. It’s purpose is to

  • 0

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

<script type="text/javascript">
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();
}   
} 
}
</script>

here is the second script that is called

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 ] ) ;
};

}())

This is what I’m calling the first routine with

onclick="checkB(this,sindex);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:25:31+00:00Added an answer on May 31, 2026 at 4:25 pm

    Two individual <script> blocks share the same execution scope, the global scope. All variables you create in the global scope inside one <script> are accessible in the other.

    <script>
        var a = 5;
    </script>
    
    <script>
        alert( a );
    </script>
    

    Same applies to functions.

    <script>
        var b = function( c ){ return c; }
    </script>
    
    <script>
        alert( b(12) );
    </script>
    

    That you can rule-out, your problem seems to lay in the first script, which is not syntactically valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a blog post from Kirk Munro that explains how a script can
I am using the php script that can be found here http://forum.madshi.net/viewtopic.php?f=4&t=26188 to report
I want to use a shell script that I can call to set some
I have a host with php+mysql and i need to run a script here
For example, my goal is to test the code given here: PHP script that
Here is my script: #!/bin/bash echo Digite o local em que deseja instalar o
Here is my script... all I want to do is have it continuously loop!
Here is my script #!/usr/bin/env ruby if __FILE__ == $0 `cd ..` puts `ls`
Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append(/home/username/python/flup) sys.path.append(/home/username/python/django) # more path
i want to upload two files. here is the script <? ini_set('memory_limit', 400M); ini_set('file_uploads',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.