Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which part of this script generates a pop-up?

    Hello

    I needed an interdependent form for my website and found a JavaScript that would do the trick.

    Now i have no knowledge in JavaScript but i managed to set this up right. But i seems some part of the script makes a popup window which is showing what is chosen in the form and i reeeally want to remove that

    Can anyone pick out which piece of the script i need to remove?

    Thanks in advance

    Code:
    var ss2Values = [
      // 'Please choose a subject'
      ['Please choose a category'],
      // '3D Printer'
      ['Please choose a category', 'Darwin', 'Huxley', 'MendelMax', 'Original Mendel', 'Printrbot', 'Prusa Mendel', 'Wallace', 'Upgrades'],
      // 'Home'
      ['Please choose a category', 'Bathroom', 'Bedroom', 'Decorations', 'Furniture', 'Home utilities', 'Household items', 'Kitchen', 'Livingroom', 'Outdoor', 'Spareparts'],
      // 'Mechanical'
      ['Please choose a category', 'Gears', 'Nuts and bolts', 'Tracks and bogies'],
      // 'Electrical'
      ['Please choose a category', 'Battery boxes', 'Terminal blocks', 'Outlet boxes'],
      // 'Electrical'
      ['Please choose a category', 'Architectural', 'Games', 'Ornaments', 'Toys'],
      // 'Educational'
      ['Please choose a category', 'Biological models', 'Chemical models', 'Mathematical', 'Physical models']
    ];
    window.onload = function()
    {
      var ss2 = new xSubSelect('sel20', 'sel21', null, ss2Values, ss2OnChange);
    }
    function ss1OnChange(s0, s1, s2)
    {
      alert(
        s0.options[s0.selectedIndex].value + ' / '
        + s1.options[s1.selectedIndex].value + ' / '
        + s2.options[s2.selectedIndex].value
      );
    }
    function ss2OnChange(s0, s1)
    {
      alert(
        s0.options[s0.selectedIndex].value + ' / '
        + s1.options[s1.selectedIndex].value
      );
    }
    function xSubSelect(sSelId0, sSelId1, sSelId2, aValues, fnOnChange)
    {
      var s0 = document.getElementById(sSelId0);
      var s1 = document.getElementById(sSelId1);
      var s2 = sSelId2 ? document.getElementById(sSelId2) : null;
      if (s0 && s1)
      {
        s0.onchange = function()
        {
          var i, len, val;
          // clear existing options for s1
          len = s1.options.length;
          for (i = 0; i < len; ++i)
          {
            s1.options[0] = null;
          }
          // insert new options for s1
          len = aValues[s0.selectedIndex].length;
          for (i = 0; i < len; ++i)
          {
            val = aValues[s0.selectedIndex][i];
            s1.options[i] = new Option(s2 ? val[0] : val);
          }
          // update s2
          if (s2)
          {
            s1.onchange();
          }
        };
        if (s2)
        {
          s1.onchange = function()
          {
            var i, len;
            // clear existing options for s2
            len = s2.options.length;
            for (i = 0; i < len; ++i)
            {
              s2.options[0] = null;
            }
            // insert new options for s2
            len = aValues[s0.selectedIndex][s1.selectedIndex].length;
            for (i = 1; i < len; ++i)
            {
              s2.options[i - 1] = new Option(aValues[s0.selectedIndex][s1.selectedIndex][i]);
            }
          };
          s2.onchange = function()
          {
            if (fnOnChange)
            {
              fnOnChange(s0, s1, s2);
            }
          };
        }
        else
        {
          s1.onchange = function()
          {
            if (fnOnChange)
            {
              fnOnChange(s0, s1);
            }
          };
        }
        s0.onchange(); // first init
      }
    }

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,467
    Thanks
    3
    Thanked 495 Times in 482 Posts
    change

    Code:
    window.onload = function()
    {
      var ss2 = new xSubSelect('sel20', 'sel21', null, ss2Values, ss2OnChange);
    }
    to
    Code:
    window.onload = function()
    {
      var ss2 = new xSubSelect('sel20', 'sel21', null, ss2Values,false);
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot, working perfectly


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •