Get your own Vue server
  <h1>Select Multiple in Vue</h1>
  <p>Depending on your operating system, use the 'ctrl' or the 'command' key to select multiple options.</p>
  <form @submit.prevent="registerAnswer">
    <label for="cars">Choose one or more cars:</label><br>
    <select  v-model="carsSelected" id="cars" multiple>
    <button type="submit">Submit</button>
    <h3>Submitted answer:</h3>
    <p id="pAnswer">{{ inpValSubmitted }}</p>

export default {
  data() {
    return {
      carsSelected: [],
      inpValSubmitted: 'Not submitted yet'
  methods: {
    registerAnswer() {
      if(this.carsSelected) {
        this.inpValSubmitted = this.carsSelected;

<style scoped>
  div {
    border: dashed black 1px;
    border-radius: 10px;
    padding: 0 20px 20px 20px;
    margin-top: 20px;
    display: inline-block;
  button, select {
    margin: 10px;
    display: block;
  label {
    width: 80px;
    padding: 5px;
  label:hover {
    cursor: pointer;
    background-color: rgb(211, 244, 211);
    border-radius: 5px;
  #pAnswer {
    background-color: lightgreen;
    padding: 5px;
import { createApp } from 'vue'

import App from './App.vue'

const app = createApp(App)