in Education by
I have created a fiddle to explain what I want : https://jsfiddle.net/silentway/aro5kq7u/3/ The standalone code is as follows :

This is my main list.

And this is the list of the selected elements in the previous list.

  • {{questions[a.id]}}

Here's the answer's array for debugging: {{answers}}

var mainApp = new Vue({ el: '#mainApp', data: { questions: [ "Who are you ?", "Who, who?", "You know my name?", "Look up my number" ], answers: [] } }); I want to display a first list of questions, each with a checkbox. The selected questions are stored in an array called "answers". From these selected answers I then make another list. Each item has a new corresponding checkbox, for a certain property (which can be true or false). I would like this associated property to be stored in the same array ("answers") as the results from the input in the first list. What happens with my code is that checking a box in the second list does change the shared array of data ("answers"), but in doing so it also unchecks the corresponding answer in the first list. Any help would be much appreciated. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I'm having a very hard time following your wording but I gave it a shot anyway. I think you'd be better off keeping selected questions and selected answers in their own array and use a computed property to join them basically. Here's a quick fiddle of it: https://jsfiddle.net/crswll/d8e1g750/21/ new Vue({ data: { questions: [{ id: 1, question: 'What the heck 1?' }, { id: 2, question: 'What the heck 2?' }, { id: 3, question: 'What the heck 3?' }, { id: 4, question: 'What the heck 4?' }, { id: 5, question: 'What the heck 5?' }, ], selectedQuestions: [], selectedAnswers: [], }, computed: { answers() { return this.selectedQuestions.map(id => this.questions.find(question => question.id === id) ) }, selectedAnswersSimpleList() { return this.selectedAnswers .map(id => this.questions.find(question => question.id === id)) .map(question => question.question) } }, }).$mount('#app')

Related questions

0 votes
    I have two functions in my store, one that gets data by calling API and one that toggles change ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    With a chrome plugin, I changed my timezone to +14. However, I saw that the calendar app is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Basically I need to add the script to the head of my index.html, so what I've tried is... in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    Basically I need to add the script to the head of my index.html, so what I've tried is... in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    Question No.1: What do you understand about container tag and empty tag, give example? Question No.2: What do ... all the attributes? Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    write algorithm and flowchart the inputs two numbers swaps these values without using third variable Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    How to combine two Excel files with the same fields but different data (different years)?...
asked Oct 29, 2020 in Technology by JackTerrance
0 votes
    Joining two lists can be achieved either using the _________ function. (a) Concat (b) Join (c) Reduce (d) ... and Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Point out the wrong statement. (a) Each universal function takes array inputs and produces array outputs (b) Broadcasting ... input arguments are ndarrays (d) All of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    What is true about array 1. Can have combination of data types in a single array list 2. Must have same data types for array list...
asked Feb 24, 2021 in Technology by JackTerrance
0 votes
    What is true about array, Can have combination of data types in a single array list. Must have same data types for array list?...
asked Oct 9, 2020 in Technology by JackTerrance
0 votes
    This is an exercise for the CS guys to shine with the theory. Imagine you have 2 containers with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 15, 2022 in Education by JackTerrance
0 votes
    The ADT list is more general than common lists and has entries that are objects of the same type. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Which of the following method creates a new array object that looks at the same data? (a) view (b) ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
...