html - How to get the value of dynamically created dropdown using javascript? And get all values -


  1. here drop down list created dynamically.

  2. we able first value rest of value displayed same first value.

  3. and need concatenate values.

  4. when change number of conditions it's getting added existing one.

can me on these? note: need solution in javascript.

    var counter = 1;      var str="";      var con="";        function addinput(divname) {          var count=document.getelementbyid("conditionid").value;           for(i=1;i<=count;i++)           {                var newdiv = document.createelement('div');                newdiv.innerhtml = "condition " + (counter + 0) + " <br><input list='alert' onchange='getcondition();' id='value'>";                document.getelementbyid(divname).appendchild(newdiv);                counter++;                             }                         }        function getcondition()       {                     str = document.getelementbyid("value").value;          con=con.concat(str);          alert(con);      }
<html>          <head>              <title>formatter</title>              <meta charset="utf-8">              <meta name="viewport" content="width=device-width, initial-scale=1.0">          </head>          <body>              <form>              <div id="dynamicinput">                                    number of condition:<input type="number" id="conditionid" onchange="addinput('dynamicinput');">                                    <br/>                                   <datalist id='alert'>                  <option>demo 1</option>                  <option>demo 2</option>                  <option>demo 3</option>                  <option>demo 4</option>                  <option>demo 5</option>                  <option>demo 6</option>                  </datalist>           </div>                   </form>      </body>      </html>

here i'm getting first value right, , other value same first value.need change per selection.

you can specific value, if know element should select.

first of all, in js function addinput generating bunch of inputs same id. bad. try this: ... id='value' + i

second, think should add different identificators options. specific id can info want.

or can array of option elements. have know index of each option


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -