cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <form id="app">

  <div class="grid">
    <div class="left">
      <select v-model="left" multiple size=10>
        <option v-for="item in leftItems" :key="item.id" 
                :value="item">{{item.name}}</option>
      </select>
    </div>
    
    <div class="middle">
      <button @click.prevent="moveLeft">&lt;-</button>
      <button @click.prevent="moveRight">-&gt;</button>
    </div>
    
    <div class="right">
      <select v-model="right" multiple size=10>
         <option v-for="item in rightItems" :key="item.id" 
                :value="item">{{item.name}}</option>       
      </select>
    </div>
  </div>

  <!-- debug -->
  <p>
    leftItems: {{ leftItems}}<br/>
    left: {{ left}}<br/>
    rightItems: {{ rightItems }}<br/>
    right: {{ right }}
  </p>
  
</form>
  

            
          
!
            
              select {
  width: 100px;
}

.grid {
   display: grid;
  grid-template-columns: repeat(3, 33%);
  grid-gap: 10px;
  width: 500px;
}

button {
  height: 40px;
  width: 40px;
}
            
          
!
            
              const app = new Vue({
  el:'#app',
  data:{
    left:[],
    right:[],
    leftItems:[],
    rightItems:[],
    items:[
      {id:1,name:"Fred"},
      {id:2,name:"Ginger"},
      {id:3,name:"Zeus"},
      {id:4,name:"Thunder"},
      {id:5,name:"Midnight"}
    ]
    
  },
  created() {
    this.leftItems = this.items;
  },
  methods:{
    moveRight() {
      if(this.left.length === 0) return;
      console.log('move right');
      //copy all of this.left to this.rightItems
      //then set this.left to []
      for(let x=this.leftItems.length-1;x>=0;x--) {
        let exists = this.left.findIndex(ob => {
          return (ob.id === this.leftItems[x].id);
        });
        if(exists >= 0) {
          this.rightItems.push(this.leftItems[x]);
          this.leftItems.splice(x,1);
        }
      }
    },
    moveLeft() {
      if(this.right.length === 0) return;
      console.log('move left');
      for(let x=this.rightItems.length-1;x>=0;x--) {
        let exists = this.right.findIndex(ob => {
          return (ob.id === this.rightItems[x].id);
        });
        if(exists >= 0) {
          this.leftItems.push(this.rightItems[x]);
          this.rightItems.splice(x,1);
        }
      }
    }
    
  }
})
            
          
!
999px
Loading ..................

Console