Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
How to use HTML input, select, checkbox field in Vue JS loop and get the data's as Array

I have this for lop in my Vue JS application:

<b-form>    
    <table class="table">
        <thead>
            <tr>
                <th>Import Field</th>
                <th>Project Field</th>
                <th>Select</th>
            </tr>
        </thead>
        <tbody>
            <tr
                v-for="(data, index) in projectFieldOptions"
                :key="index"
            >
                <td>
                    <b-form-input
                        class="basicInput"
                        v-model="data.text"
                    />
                </td>
                <td>
                    <b-form-select
                        v-model="
                            selectedProjectOption
                        "
                        :options="
                            projectFieldOptions
                        "
                    />
                </td>
                <td>
                    <b-form-checkbox
                        v-model="selectMap"
                        checked="false"
                        name="check-button"
                        switch
                        inline
                    >
                    </b-form-checkbox>
                </td>
            </tr>
        </tbody>
    </table>
    <b-button
        variant="primary"
        type="submit"
        @click.prevent="validateEditMapping"
    >
        Next
    </b-button>
</b-form>

It's showing this output:

You can see there are 3 fields:

  1. Import Field ( as input box )
  2. Project Field ( as select dropdown )
  3. Select ( as checkbox )

Now,

  1. How can I get all the input, select and checkbox fields as array in Vue JS?
  2. If I change the Project field dropdown then other dropdowm is also changed but it's should change my selected dropdown only. How can I solve it?

I want the output should like this:

[
   { item, imte, 0 },
   { description, description, 1},
    ....
]

enter image description here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I will start with the answer to the second question. Just like you have data.text assigned to v-model in b-form-input, you should make something similar for b-form-select and b-form-checkbox e.g.

<b-form-select
  v-model="data.selectedProjectOption"
  :options="projectFieldOptions"
/>

otherwise, you will have selectedProjectOption variable assigned to every b-form-select component, so if you change its value in one of them it will change the value in others as well.

For the first question, let's assume you projectFieldOptions look like this:

projectFieldOptions = [
  {text: 'text', selectedProjectOption: 'option', selectMap: 0, ...},
  {text: 'text1', selectedProjectOption: 'option1', selectMap: 1, ...},
  ...,
]

you can map this array to receive desired output.

const projectFieldOptions = [{
    text: 'text',
    selectedProjectOption: 'option',
    selectMap: 0
  },
  {
    text: 'text1',
    selectedProjectOption: 'option1',
    selectMap: 1
  },
]

const mappedArray = projectFieldOptions.map((e) => {
  return [e.text, e.selectedProjectOption, e.selectMap]
});

console.log(mappedArray);

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!