Add dynamic dropdown on button click and getting the dropdown valuesTrigger a button click with JavaScript on the Enter key in a text boxHow can I get query string values in JavaScript?How to get the value from the GET parameters?Get selected value in dropdown list using JavaScriptHow can I add a key/value pair to a JavaScript object?Is it possible to add dynamically named properties to JavaScript object?Get all unique values in a JavaScript array (remove duplicates)jQuery Get Selected Option From DropdownHow to set default option for dynamic drop down buttons in jQuery?How to set value in session storage with vueJS by ajax dropdown select to other changes value

Is multiplication of real numbers uniquely defined as being distributive over addition?

Does this smartphone photo show Mars just below the Sun?

Unexpected route on a flight from USA to Europe

Where is the rule for moving slowly when searching for traps that’s referenced by Dungeon Delver?

How quickly could a country build a tall concrete wall around a city?

Should I self-publish my novella on Amazon or try my luck getting publishers?

How does The Fools Guild make its money?

Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?

Secure my password from unsafe servers

WordCloud: do not eliminate duplicates

Looking for a new job because of relocation - is it okay to tell the real reason?

Why does the ultra long-end of a yield curve invert?

How to draw a flow chart?

Why do private jets such as Gulfstream fly higher than other civilian jets?

Ampacity of Conductive Tape

How do I get the =LEFT function in excel, to also take the number zero as the first number?

Scripting a Maintenance Plan in SQL Server Express

Does the length of a password for Wi-Fi affect speed?

Is there a loss of quality when converting RGB to HEX?

How can I tell if a flight itinerary is fake

Erratic behavior by an internal employee against an external employee

What can make Linux unresponsive for minutes when browsing certain websites?

What does Fisher mean by this quote?

Can ads on a page read my password?



Add dynamic dropdown on button click and getting the dropdown values


Trigger a button click with JavaScript on the Enter key in a text boxHow can I get query string values in JavaScript?How to get the value from the GET parameters?Get selected value in dropdown list using JavaScriptHow can I add a key/value pair to a JavaScript object?Is it possible to add dynamically named properties to JavaScript object?Get all unique values in a JavaScript array (remove duplicates)jQuery Get Selected Option From DropdownHow to set default option for dynamic drop down buttons in jQuery?How to set value in session storage with vueJS by ajax dropdown select to other changes value






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have added html select options dynamically while clicking on button



<div id="app">
<div>
<button class="button btn-primary" @click="addRow">Add row</button>
<button @click="showValues">
Show values
</button>
</div>
<div v-for="row in rows" :id=row.id>
<button-counter></button-counter>
</div>
</div>
<script>

Vue.component('button-counter',
props: ['value'],
template: '<select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select>'
)
var app = new Vue(
el: "#app",
data:
rows: [],
values: ,
count: 0,
selected: ''
,
methods:
addRow: function ()
var txtCount = ++this.count;
id = 'ddl_' + txtCount;
this.rows.push( title: "first", description: "ddl1", id );

,
showValues()
console.log(this.values)



);
</script>


I am using component for adding html select dynamically.when i click on Add row button, new drop down will add. My problem is i want to get drop down values on Show values button click.










share|improve this question
































    0















    I have added html select options dynamically while clicking on button



    <div id="app">
    <div>
    <button class="button btn-primary" @click="addRow">Add row</button>
    <button @click="showValues">
    Show values
    </button>
    </div>
    <div v-for="row in rows" :id=row.id>
    <button-counter></button-counter>
    </div>
    </div>
    <script>

    Vue.component('button-counter',
    props: ['value'],
    template: '<select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select>'
    )
    var app = new Vue(
    el: "#app",
    data:
    rows: [],
    values: ,
    count: 0,
    selected: ''
    ,
    methods:
    addRow: function ()
    var txtCount = ++this.count;
    id = 'ddl_' + txtCount;
    this.rows.push( title: "first", description: "ddl1", id );

    ,
    showValues()
    console.log(this.values)



    );
    </script>


    I am using component for adding html select dynamically.when i click on Add row button, new drop down will add. My problem is i want to get drop down values on Show values button click.










    share|improve this question




























      0












      0








      0








      I have added html select options dynamically while clicking on button



      <div id="app">
      <div>
      <button class="button btn-primary" @click="addRow">Add row</button>
      <button @click="showValues">
      Show values
      </button>
      </div>
      <div v-for="row in rows" :id=row.id>
      <button-counter></button-counter>
      </div>
      </div>
      <script>

      Vue.component('button-counter',
      props: ['value'],
      template: '<select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select>'
      )
      var app = new Vue(
      el: "#app",
      data:
      rows: [],
      values: ,
      count: 0,
      selected: ''
      ,
      methods:
      addRow: function ()
      var txtCount = ++this.count;
      id = 'ddl_' + txtCount;
      this.rows.push( title: "first", description: "ddl1", id );

      ,
      showValues()
      console.log(this.values)



      );
      </script>


      I am using component for adding html select dynamically.when i click on Add row button, new drop down will add. My problem is i want to get drop down values on Show values button click.










      share|improve this question
















      I have added html select options dynamically while clicking on button



      <div id="app">
      <div>
      <button class="button btn-primary" @click="addRow">Add row</button>
      <button @click="showValues">
      Show values
      </button>
      </div>
      <div v-for="row in rows" :id=row.id>
      <button-counter></button-counter>
      </div>
      </div>
      <script>

      Vue.component('button-counter',
      props: ['value'],
      template: '<select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> </select>'
      )
      var app = new Vue(
      el: "#app",
      data:
      rows: [],
      values: ,
      count: 0,
      selected: ''
      ,
      methods:
      addRow: function ()
      var txtCount = ++this.count;
      id = 'ddl_' + txtCount;
      this.rows.push( title: "first", description: "ddl1", id );

      ,
      showValues()
      console.log(this.values)



      );
      </script>


      I am using component for adding html select dynamically.when i click on Add row button, new drop down will add. My problem is i want to get drop down values on Show values button click.







      javascript vue.js vuejs2 vue-component






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 8:59







      Basil Joy

















      asked Mar 27 at 5:50









      Basil JoyBasil Joy

      461 gold badge4 silver badges13 bronze badges




      461 gold badge4 silver badges13 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1














          For accessing value what you can do is add ref to all components and get the value of the v-model using the $ref but for that, you need to add the v-model to the select component. I have created the plunker with your code and its working fine. For more detail please refer the codepen.



          codepen - https://codepen.io/anon/pen/Qoeybv






          share|improve this answer
































            0














            I see that you have one "Show values button click", but can exist many select HTML elements. Have to decide which element you want to get. If you want to get all it can be done in this.$children as array of objects. See this [enter link description here][1]. I'm new at vue.js and I do not claim to be a good practice / solution. There is added event on each select (for example) and show last select element in showValues().



            [1]: https://codepen.io/iganchev87/pen/xBvOMJ





            share|improve this answer



























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370593%2fadd-dynamic-dropdown-on-button-click-and-getting-the-dropdown-values%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              For accessing value what you can do is add ref to all components and get the value of the v-model using the $ref but for that, you need to add the v-model to the select component. I have created the plunker with your code and its working fine. For more detail please refer the codepen.



              codepen - https://codepen.io/anon/pen/Qoeybv






              share|improve this answer





























                1














                For accessing value what you can do is add ref to all components and get the value of the v-model using the $ref but for that, you need to add the v-model to the select component. I have created the plunker with your code and its working fine. For more detail please refer the codepen.



                codepen - https://codepen.io/anon/pen/Qoeybv






                share|improve this answer



























                  1












                  1








                  1







                  For accessing value what you can do is add ref to all components and get the value of the v-model using the $ref but for that, you need to add the v-model to the select component. I have created the plunker with your code and its working fine. For more detail please refer the codepen.



                  codepen - https://codepen.io/anon/pen/Qoeybv






                  share|improve this answer













                  For accessing value what you can do is add ref to all components and get the value of the v-model using the $ref but for that, you need to add the v-model to the select component. I have created the plunker with your code and its working fine. For more detail please refer the codepen.



                  codepen - https://codepen.io/anon/pen/Qoeybv







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 16:19









                  Patel PratikPatel Pratik

                  7262 silver badges12 bronze badges




                  7262 silver badges12 bronze badges


























                      0














                      I see that you have one "Show values button click", but can exist many select HTML elements. Have to decide which element you want to get. If you want to get all it can be done in this.$children as array of objects. See this [enter link description here][1]. I'm new at vue.js and I do not claim to be a good practice / solution. There is added event on each select (for example) and show last select element in showValues().



                      [1]: https://codepen.io/iganchev87/pen/xBvOMJ





                      share|improve this answer





























                        0














                        I see that you have one "Show values button click", but can exist many select HTML elements. Have to decide which element you want to get. If you want to get all it can be done in this.$children as array of objects. See this [enter link description here][1]. I'm new at vue.js and I do not claim to be a good practice / solution. There is added event on each select (for example) and show last select element in showValues().



                        [1]: https://codepen.io/iganchev87/pen/xBvOMJ





                        share|improve this answer



























                          0












                          0








                          0







                          I see that you have one "Show values button click", but can exist many select HTML elements. Have to decide which element you want to get. If you want to get all it can be done in this.$children as array of objects. See this [enter link description here][1]. I'm new at vue.js and I do not claim to be a good practice / solution. There is added event on each select (for example) and show last select element in showValues().



                          [1]: https://codepen.io/iganchev87/pen/xBvOMJ





                          share|improve this answer













                          I see that you have one "Show values button click", but can exist many select HTML elements. Have to decide which element you want to get. If you want to get all it can be done in this.$children as array of objects. See this [enter link description here][1]. I'm new at vue.js and I do not claim to be a good practice / solution. There is added event on each select (for example) and show last select element in showValues().



                          [1]: https://codepen.io/iganchev87/pen/xBvOMJ






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 28 at 17:58









                          Ivan GanchevIvan Ganchev

                          791 silver badge7 bronze badges




                          791 silver badge7 bronze badges






























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370593%2fadd-dynamic-dropdown-on-button-click-and-getting-the-dropdown-values%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현