Hi,

Below I post js code from jquery website.

$(document).ready(function() {
    var selected = new Array();

   $('select').mouseover(function() {
      if (this.multiple == true) {
        for (var i=0,a=0;i<this.options.length;i++) {
          if (this.options[i].selected == true) {
            selected[a] = this.options[i].value;
            a++;
          }
        }
      }
    });

    // safe them when you click the mouse
    $('select').click(function() {
      // make sure it's a multiple select
      if (this.multiple == true) {
        for(var i=0;i<selected.length;i++) {
          for(var a=0;a<this.options.length;a++){
            if (selected[i] == this.options[a].value && this.options
[a].selected == true) {
              this.options[a].selected = false;
              selected.splice(i,1);                             /*
CONFUSON */
             } else if (selected[i] == this.options[a].value) {
              this.options[a].selected = true;
            }
          }
        }
      }

      // load all selected options in array when the mouse pointer
hovers the select box
      if (this.multiple == true) {
        for (var i=0,a=0;i<this.options.length;i++) {
          if (this.options[i].selected == true) {
            selected[a] = this.options[i].value;
            a++;
          }
        }
      }

    });
  });



This js file is used with html file for selecting more than one
without pressing ctrl key.
I am confused with line selected.splice(i,1);  which means starts
splicing(joining) from index i to 1.

I changed value 1 to 2 and then 3 but I do not get any difference when
I open browser and test.
Can anybody please clear this.

Reply via email to