Instructions on how to automatically update the label of a <v-file-input> with the value selected from a <v-select> in Vuetify

As a novice, I am currently working on creating a Vuetify form that includes three <v-file-input> elements, each with a corresponding <v-select> option. My goal is to update the label of each <v-file-input> with the selected value from its respective <v-select>.

I would greatly appreciate any assistance in solving this issue. You can find my code on CodePen: https://codepen.io/jx46/full/pooMwQp

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    items: ['one', 'two', 'three']
  })
})
<!DOCTYPE html>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="badcd5d4cefa8e94c2">[email protected]</a>/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88fefdedfce1eef1c8baa6f0">[email protected]</a>/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>

<body>
  <div id="app">
    <v-app>
      <v-content>
        <v-container>

          <v-form>
            <v-row>
              <v-col>
                <v-select :items="items" label="Standard"></v-select>
              </v-col>
              <v-col>
                <v-file-input label="File input"></v-file-input>
              </v-col>
            </v-row>

            <v-row>
              <v-col>
                <v-select :items="items" label="Standard"></v-select>
              </v-col>
              <v-col>
                <v-file-input label="File input"></v-file-input>
              </v-col>
            </v-row>

            <v-row>
              <v-col>
                <v-select :items="items" label="Standard"></v-select>
              </v-col>
              <v-col>
                <v-file-input label="File input"></v-file-input>
              </v-col>
            </v-row>

          </v-form>

        </v-container>
      </v-content>
    </v-app>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f191a0a2f5d4117">[email protected]</a>/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82f4f7e7f6ebe4fbc2b0acfa">[email protected]</a>/dist/vuetify.js"></script>
</body>

</html>

Answer №1

To ensure proper functionality, it is necessary to define the data for each pair of components (v-select and v-input). Then bind them using v-model and :label.

Here's an example template:

<v-select
   v-model="firstSelectValue"                   
   :items="items"
   label="Standard"
></v-select>
<v-file-input :label="firstSelectValue"></v-file-input>

JS:

data: () => ({
   items: ['one','two','three'],
   firstSelectValue: 'File input',
   secondSelectValue: 'File input',
   thirdSelectValue: 'File input',
})

Updated Codepen link: https://codepen.io/RobbyFront/pen/eYYqEBx

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method for sending a PHP variable to an AJAX request?

I am working with three files - my main PHP file, functions.php, and my JS file. My challenge is to pass a PHP variable to JavaScript. Below is a snippet from my MAIN PHP FILE: function ccss_show_tag_recipes() { //PHP code here } Next, here's t ...

How can I use jQuery to add animation to the coloring of an SVG graphic?

I want to create a dynamic animation for my SVG using jQuery. I aim to first animate the path of the SVG, and then after the initial animation, I would like to animate the fill of the SVG with specified duration and easing function. Is it possible to achi ...

Utilizing Laravel's Eloquent to retrieve interrelated data from tables through foreign keys

I am looking to retrieve fields from a controller using Eloquent with the data of another class through foreign keys. I am unsure if this is possible or not. The situation Model Job class Job extends Model { use HasFactory; /** * The attr ...

Implementing Material UI Slider component to update state upon mouse release, enabling real-time sliding functionality

Is there a way to update the new state only upon mouse release for a Material UI slider, while still allowing real-time tracking of the slide? Material UI offers two events: onChange and onChangeCommitted. The latter gives the desired end result, but the s ...

Creating clickable div elements within a loop

In the .JS file I have the function below (which I later call in an HTML file): function writeDiv(){ x = 1 myArray.forEach(item => { htmlText += '<div class="divsArray">'; htmlText += '<h5> Value of X ...

What is the best way to keep the calendar of a Datepicker always visible while still being able to select a date easily?

When I write my code, the calendar only appears when I press the TextBox. I attempted to place the datepicker in a <div>, but then I was unable to retrieve the selected date. @model Plotting.Models.CalendarModel @using (Html.BeginForm("Calendar", "H ...

Determine all the names of imported files in a source file using regular expressions in JavaScript

Hello, I'm new to working with regex and JavaScript. I'm attempting to use regex to create an array of all imported files in a source file. In the source file, there is an '@' sign before an import statement. For example, if the file lo ...

What counterpart in JavaScript resembles the .NET Standard Class Library?

As someone transitioning from a background in .NET to learning Vue.js, I'm curious about the best way to create classes that handle business logic for me. Specifically, I want to be able to fetch information from an API, format it as needed and easily ...

Adjusting the aspect ratio of an ortographic camera when resizing

Is there a method to configure an orthographic camera in THREE.JS in a way that: 1)It retains a consistent aspect ratio regardless of window resizing. This aspect ratio should remain constant and not be affected by the window's dimensions or aspect r ...

jQuery event.preventDefault not functioning as expected

I am attempting to use jQuery's preventDefault() method, but when I submit the form, it still displays the default behavior and reloads the page. Here is the code from index.html: <body> <script src="/socket.io/socket.io.js"></script& ...

Search for a result based on a connection, but ensure that the association is not included in the final outcome when using

Basically, I'm trying to search for something in a table using the method include: [{ model, where }], but without actually including the model itself. I have two models, Part and Set, with a one-to-many connection. I am looking for Parts that are re ...

How to inject a variable into an AngularJS service that utilizes both $http and $interval functions?

Struggling with $http and $interval, I stumbled upon this code. http://embed.plnkr.co/fSIm8B/script.js I forked it here: http://plnkr.co/edit/Al8veEgvESYA0rhKLn1q To make it more functional, how can I pass a variable to the service? Here is the broken ...

What is causing the discrepancy in functionality between these two HTML/CSS files with identical code?

In this codepen, you'll find the first example: Subpar Pen: https://codepen.io/anon/pen/jGpxrp Additionally, here is the code for the second example: Excellent Pen: https://codepen.io/anon/pen/QqBmWK?editors=1100 I'm puzzled why the buttons l ...

How to use mousedown event in Three.js to create line drawings

I've tried multiple approaches to achieve this effect. I'm looking to draw a line on mouse down event, and despite researching various resources, I haven't been able to come up with a solution. Currently, I'm utilizing the RayCaster met ...

Guide on setting the HTML img src value with AR.ImageResource in ARchitectBrowser.html while utilizing the Wikitude SDK for iOS

I am currently customizing the ARchitectBrowser.html file provided by the Wikitude SDK for iOS and I am interested in finding a way to directly insert an image set in AR.ImageResource. bubbleImage = new AR.ImageResource("http://graph.facebook.com/" + json ...

Transform a nested array of objects into a distinct set of objects based on the data in JavaScript or TypeScript

I have a unique situation where I am dealing with a double nested array of objects, and I need to restructure it into a specific array format to better align with my table structure. Here are the current objects I'm working with and the desired resul ...

What is the best way to save and retain cache data for an audio file?

I have a website where I am using an audio file in .swf format. This audio file can be turned on and off with the options provided: AUDIO ON and AUDIO OFF. However, I am facing the issue that the audio keeps playing repeatedly even after being turned off. ...

Obtaining the date for the previous month using JavaScript or jQuery

I need to retrieve a specific date in JavaScript. My goal is to obtain the current date based on a variable named frequency, which can have values of Daily, Weekly, or Monthly. if(frequency=="daily") { date='current_date -2 days'; } e ...

Renaming the month in Material-UI React

Using DatePicker from Material Ui, I am trying to change the name of the month. How can this be achieved? For instance, I need to change August to Avqust or March to Mart enter image description here This is my code: <LocalizationProvider ...

Implement safe instructions through communication between the client and server

I am currently using Fancy WebSockets in Javascript for communication with my php server to support my multiplayer game. At the moment, I am simply sending raw sockets (json) as Sending: {"command": "login", "data": {"id" : "1575","md5" : "6bd8937a8789a3 ...