unable to display select fields side by side?












1















while selecting fields for child age then it will display two select field
but they are not showing inline side by side.
i just want them inline side means side by side like first two select field are.
here is my code.






function addFields() {
var number = document.getElementById("selected_childs").value;
var childage = document.getElementById("childage");

//Create array of options to be added
var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

while (childage.hasChildNodes()) {
childage.removeChild(childage.lastChild);
}
if (number == 1) {
// statement
for (i = 0; i < number; i++) {
childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

var selectList = document.createElement("select");
selectList.setAttribute("id", "mySelect");
selectList.setAttribute("class", "form-control");
childage.appendChild(selectList);
childage.appendChild(document.createElement("br"));

//Create and append the options
for (var j = 0; j < array.length; j++) {
var option = document.createElement("option");
option.setAttribute("value", array[j]);
option.text = array[j];
selectList.appendChild(option);
}
}
} else {
// statement
for (i = 0; i < number; i++) {
childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

var selectList = document.createElement("select");
selectList.setAttribute("id", "mySelect");
selectList.setAttribute("class", "form-control");
childage.appendChild(selectList);
childage.appendChild(document.createElement("br"));

//Create and append the options
for (var j = 0; j < array.length; j++) {
var option = document.createElement("option");
option.setAttribute("value", array[j]);
option.text = array[j];
selectList.appendChild(option);
}
}

}
}

<!DOCTYPE html>
<html>
<head>
<title>Welcome|Home</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
<div class="this_is_field_wrapper">
<div class="row">
<div class="form-group">
<div class="col-xs-1">
<h6>Options -</h6>
<h6 class="#">Adults(12+)</h6>
<select id="selected_adults" name="selected_adults" class="form-control">
<option value="1">1</option>
<option selected="selected" value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<!-- </div>
<div class="form-group"> -->
<div class="col-xs-1">
<h6>1st Room</h6>
<h6 class="m_label">Child(0-12)</h6>
<select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
<option>--select--</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<!-- </div>
<div class="form-group"> -->
<div id="childage" class="col-xs-1">
</div>
<!-- </div>
<div class="form-group"> -->
<div id="childage" class="col-xs-1">
</div>
<div class="col-xs-1">
<a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
</div>
</div>
<!-- here ending form group -->
</div>
<!-- here ending row -->
</div>
<button type="submit" value="submit">click to submit</button>
</form>
</body>
</html>





The problem is
when you select child room by selecting field they it will display two field but they are displaying upto down. i just want them side by side like first two select fields.
please help
thanks in advance.










share|improve this question



























    1















    while selecting fields for child age then it will display two select field
    but they are not showing inline side by side.
    i just want them inline side means side by side like first two select field are.
    here is my code.






    function addFields() {
    var number = document.getElementById("selected_childs").value;
    var childage = document.getElementById("childage");

    //Create array of options to be added
    var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

    while (childage.hasChildNodes()) {
    childage.removeChild(childage.lastChild);
    }
    if (number == 1) {
    // statement
    for (i = 0; i < number; i++) {
    childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

    var selectList = document.createElement("select");
    selectList.setAttribute("id", "mySelect");
    selectList.setAttribute("class", "form-control");
    childage.appendChild(selectList);
    childage.appendChild(document.createElement("br"));

    //Create and append the options
    for (var j = 0; j < array.length; j++) {
    var option = document.createElement("option");
    option.setAttribute("value", array[j]);
    option.text = array[j];
    selectList.appendChild(option);
    }
    }
    } else {
    // statement
    for (i = 0; i < number; i++) {
    childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

    var selectList = document.createElement("select");
    selectList.setAttribute("id", "mySelect");
    selectList.setAttribute("class", "form-control");
    childage.appendChild(selectList);
    childage.appendChild(document.createElement("br"));

    //Create and append the options
    for (var j = 0; j < array.length; j++) {
    var option = document.createElement("option");
    option.setAttribute("value", array[j]);
    option.text = array[j];
    selectList.appendChild(option);
    }
    }

    }
    }

    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome|Home</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>
    <body>
    <form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
    <div class="this_is_field_wrapper">
    <div class="row">
    <div class="form-group">
    <div class="col-xs-1">
    <h6>Options -</h6>
    <h6 class="#">Adults(12+)</h6>
    <select id="selected_adults" name="selected_adults" class="form-control">
    <option value="1">1</option>
    <option selected="selected" value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    </select>
    </div>
    <!-- </div>
    <div class="form-group"> -->
    <div class="col-xs-1">
    <h6>1st Room</h6>
    <h6 class="m_label">Child(0-12)</h6>
    <select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
    <option>--select--</option>
    <option value="1">1</option>
    <option value="2">2</option>
    </select>
    </div>
    <!-- </div>
    <div class="form-group"> -->
    <div id="childage" class="col-xs-1">
    </div>
    <!-- </div>
    <div class="form-group"> -->
    <div id="childage" class="col-xs-1">
    </div>
    <div class="col-xs-1">
    <a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
    </div>
    </div>
    <!-- here ending form group -->
    </div>
    <!-- here ending row -->
    </div>
    <button type="submit" value="submit">click to submit</button>
    </form>
    </body>
    </html>





    The problem is
    when you select child room by selecting field they it will display two field but they are displaying upto down. i just want them side by side like first two select fields.
    please help
    thanks in advance.










    share|improve this question

























      1












      1








      1








      while selecting fields for child age then it will display two select field
      but they are not showing inline side by side.
      i just want them inline side means side by side like first two select field are.
      here is my code.






      function addFields() {
      var number = document.getElementById("selected_childs").value;
      var childage = document.getElementById("childage");

      //Create array of options to be added
      var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

      while (childage.hasChildNodes()) {
      childage.removeChild(childage.lastChild);
      }
      if (number == 1) {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }
      } else {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }

      }
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Welcome|Home</title>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <!-- jQuery library -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      </head>
      <body>
      <form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
      <div class="this_is_field_wrapper">
      <div class="row">
      <div class="form-group">
      <div class="col-xs-1">
      <h6>Options -</h6>
      <h6 class="#">Adults(12+)</h6>
      <select id="selected_adults" name="selected_adults" class="form-control">
      <option value="1">1</option>
      <option selected="selected" value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div class="col-xs-1">
      <h6>1st Room</h6>
      <h6 class="m_label">Child(0-12)</h6>
      <select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
      <option>--select--</option>
      <option value="1">1</option>
      <option value="2">2</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <div class="col-xs-1">
      <a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
      </div>
      </div>
      <!-- here ending form group -->
      </div>
      <!-- here ending row -->
      </div>
      <button type="submit" value="submit">click to submit</button>
      </form>
      </body>
      </html>





      The problem is
      when you select child room by selecting field they it will display two field but they are displaying upto down. i just want them side by side like first two select fields.
      please help
      thanks in advance.










      share|improve this question














      while selecting fields for child age then it will display two select field
      but they are not showing inline side by side.
      i just want them inline side means side by side like first two select field are.
      here is my code.






      function addFields() {
      var number = document.getElementById("selected_childs").value;
      var childage = document.getElementById("childage");

      //Create array of options to be added
      var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

      while (childage.hasChildNodes()) {
      childage.removeChild(childage.lastChild);
      }
      if (number == 1) {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }
      } else {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }

      }
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Welcome|Home</title>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <!-- jQuery library -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      </head>
      <body>
      <form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
      <div class="this_is_field_wrapper">
      <div class="row">
      <div class="form-group">
      <div class="col-xs-1">
      <h6>Options -</h6>
      <h6 class="#">Adults(12+)</h6>
      <select id="selected_adults" name="selected_adults" class="form-control">
      <option value="1">1</option>
      <option selected="selected" value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div class="col-xs-1">
      <h6>1st Room</h6>
      <h6 class="m_label">Child(0-12)</h6>
      <select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
      <option>--select--</option>
      <option value="1">1</option>
      <option value="2">2</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <div class="col-xs-1">
      <a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
      </div>
      </div>
      <!-- here ending form group -->
      </div>
      <!-- here ending row -->
      </div>
      <button type="submit" value="submit">click to submit</button>
      </form>
      </body>
      </html>





      The problem is
      when you select child room by selecting field they it will display two field but they are displaying upto down. i just want them side by side like first two select fields.
      please help
      thanks in advance.






      function addFields() {
      var number = document.getElementById("selected_childs").value;
      var childage = document.getElementById("childage");

      //Create array of options to be added
      var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

      while (childage.hasChildNodes()) {
      childage.removeChild(childage.lastChild);
      }
      if (number == 1) {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }
      } else {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }

      }
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Welcome|Home</title>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <!-- jQuery library -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      </head>
      <body>
      <form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
      <div class="this_is_field_wrapper">
      <div class="row">
      <div class="form-group">
      <div class="col-xs-1">
      <h6>Options -</h6>
      <h6 class="#">Adults(12+)</h6>
      <select id="selected_adults" name="selected_adults" class="form-control">
      <option value="1">1</option>
      <option selected="selected" value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div class="col-xs-1">
      <h6>1st Room</h6>
      <h6 class="m_label">Child(0-12)</h6>
      <select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
      <option>--select--</option>
      <option value="1">1</option>
      <option value="2">2</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <div class="col-xs-1">
      <a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
      </div>
      </div>
      <!-- here ending form group -->
      </div>
      <!-- here ending row -->
      </div>
      <button type="submit" value="submit">click to submit</button>
      </form>
      </body>
      </html>





      function addFields() {
      var number = document.getElementById("selected_childs").value;
      var childage = document.getElementById("childage");

      //Create array of options to be added
      var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

      while (childage.hasChildNodes()) {
      childage.removeChild(childage.lastChild);
      }
      if (number == 1) {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }
      } else {
      // statement
      for (i = 0; i < number; i++) {
      childage.appendChild(document.createTextNode("Children Age " + (i + 1)));

      var selectList = document.createElement("select");
      selectList.setAttribute("id", "mySelect");
      selectList.setAttribute("class", "form-control");
      childage.appendChild(selectList);
      childage.appendChild(document.createElement("br"));

      //Create and append the options
      for (var j = 0; j < array.length; j++) {
      var option = document.createElement("option");
      option.setAttribute("value", array[j]);
      option.text = array[j];
      selectList.appendChild(option);
      }
      }

      }
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Welcome|Home</title>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <!-- jQuery library -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      </head>
      <body>
      <form method="POST" action="<?php echo base_url(); ?>index.php/dynamically_added_controller/Dynamically/addingValues">
      <div class="this_is_field_wrapper">
      <div class="row">
      <div class="form-group">
      <div class="col-xs-1">
      <h6>Options -</h6>
      <h6 class="#">Adults(12+)</h6>
      <select id="selected_adults" name="selected_adults" class="form-control">
      <option value="1">1</option>
      <option selected="selected" value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div class="col-xs-1">
      <h6>1st Room</h6>
      <h6 class="m_label">Child(0-12)</h6>
      <select id="selected_childs" name="selected_childs" value="" onchange="addFields()" class="form-control">
      <option>--select--</option>
      <option value="1">1</option>
      <option value="2">2</option>
      </select>
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <!-- </div>
      <div class="form-group"> -->
      <div id="childage" class="col-xs-1">
      </div>
      <div class="col-xs-1">
      <a href="javascript:void(0);" class="this_button_work_for_click_to_add_rooms" title="Add field">Click & Add Rooms</a>
      </div>
      </div>
      <!-- here ending form group -->
      </div>
      <!-- here ending row -->
      </div>
      <button type="submit" value="submit">click to submit</button>
      </form>
      </body>
      </html>






      javascript php html5 css3 bootstrap-4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 7:44









      md servermd server

      647




      647
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Your second select isnt placed in right div. See what you can do:



          function addFields() {
          var number = document.getElementById("selected_childs").value;
          var childage = document.getElementById("childage0");

          //Create array of options to be added
          var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

          while (childage.hasChildNodes()) {
          childage.removeChild(childage.lastChild);
          }
          if (number == 1) {
          // statement
          for (i = 0; i < number; i++) {
          var h = document.createElement("h6");
          var h1 = document.createElement("h6");
          h1.appendChild(document.createTextNode(" "));
          childage.appendChild(h1);

          h.appendChild(document.createTextNode("Children Age " + (i + 1)));
          childage.appendChild(h);

          var selectList = document.createElement("select");
          selectList.setAttribute("id", "mySelect");
          selectList.setAttribute("class", "form-control");
          childage.appendChild(selectList);
          childage.appendChild(document.createElement("br"));

          //Create and append the options
          for (var j = 0; j < array.length; j++) {
          var option = document.createElement("option");
          option.setAttribute("value", array[j]);
          option.text = array[j];
          selectList.appendChild(option);
          }
          }
          } else {
          // statement
          for (i = 0; i < number; i++) {
          childage = document.getElementById("childage"+i);
          var h1 = document.createElement("h6");
          h1.appendChild(document.createTextNode(" "));
          childage.appendChild(h1);
          var h = document.createElement("h6");
          h.appendChild(document.createTextNode("Children Age " + (i + 1)));
          childage.appendChild(h);

          var selectList = document.createElement("select");
          selectList.setAttribute("id", "mySelect");
          selectList.setAttribute("class", "form-control");
          childage.appendChild(selectList);
          childage.appendChild(document.createElement("br"));

          //Create and append the options
          for (var j = 0; j < array.length; j++) {
          var option = document.createElement("option");
          option.setAttribute("value", array[j]);
          option.text = array[j];
          selectList.appendChild(option);
          }
          }

          }


          }



          Add numbers to your child DIVs:



           <div id="childage0" class="col-xs-1">
          </div>
          <!-- </div>
          <div class="form-group"> -->
          <div id="childage1" class="col-xs-1">
          </div>





          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%2f53407340%2funable-to-display-select-fields-side-by-side%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Your second select isnt placed in right div. See what you can do:



            function addFields() {
            var number = document.getElementById("selected_childs").value;
            var childage = document.getElementById("childage0");

            //Create array of options to be added
            var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

            while (childage.hasChildNodes()) {
            childage.removeChild(childage.lastChild);
            }
            if (number == 1) {
            // statement
            for (i = 0; i < number; i++) {
            var h = document.createElement("h6");
            var h1 = document.createElement("h6");
            h1.appendChild(document.createTextNode(" "));
            childage.appendChild(h1);

            h.appendChild(document.createTextNode("Children Age " + (i + 1)));
            childage.appendChild(h);

            var selectList = document.createElement("select");
            selectList.setAttribute("id", "mySelect");
            selectList.setAttribute("class", "form-control");
            childage.appendChild(selectList);
            childage.appendChild(document.createElement("br"));

            //Create and append the options
            for (var j = 0; j < array.length; j++) {
            var option = document.createElement("option");
            option.setAttribute("value", array[j]);
            option.text = array[j];
            selectList.appendChild(option);
            }
            }
            } else {
            // statement
            for (i = 0; i < number; i++) {
            childage = document.getElementById("childage"+i);
            var h1 = document.createElement("h6");
            h1.appendChild(document.createTextNode(" "));
            childage.appendChild(h1);
            var h = document.createElement("h6");
            h.appendChild(document.createTextNode("Children Age " + (i + 1)));
            childage.appendChild(h);

            var selectList = document.createElement("select");
            selectList.setAttribute("id", "mySelect");
            selectList.setAttribute("class", "form-control");
            childage.appendChild(selectList);
            childage.appendChild(document.createElement("br"));

            //Create and append the options
            for (var j = 0; j < array.length; j++) {
            var option = document.createElement("option");
            option.setAttribute("value", array[j]);
            option.text = array[j];
            selectList.appendChild(option);
            }
            }

            }


            }



            Add numbers to your child DIVs:



             <div id="childage0" class="col-xs-1">
            </div>
            <!-- </div>
            <div class="form-group"> -->
            <div id="childage1" class="col-xs-1">
            </div>





            share|improve this answer




























              1














              Your second select isnt placed in right div. See what you can do:



              function addFields() {
              var number = document.getElementById("selected_childs").value;
              var childage = document.getElementById("childage0");

              //Create array of options to be added
              var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

              while (childage.hasChildNodes()) {
              childage.removeChild(childage.lastChild);
              }
              if (number == 1) {
              // statement
              for (i = 0; i < number; i++) {
              var h = document.createElement("h6");
              var h1 = document.createElement("h6");
              h1.appendChild(document.createTextNode(" "));
              childage.appendChild(h1);

              h.appendChild(document.createTextNode("Children Age " + (i + 1)));
              childage.appendChild(h);

              var selectList = document.createElement("select");
              selectList.setAttribute("id", "mySelect");
              selectList.setAttribute("class", "form-control");
              childage.appendChild(selectList);
              childage.appendChild(document.createElement("br"));

              //Create and append the options
              for (var j = 0; j < array.length; j++) {
              var option = document.createElement("option");
              option.setAttribute("value", array[j]);
              option.text = array[j];
              selectList.appendChild(option);
              }
              }
              } else {
              // statement
              for (i = 0; i < number; i++) {
              childage = document.getElementById("childage"+i);
              var h1 = document.createElement("h6");
              h1.appendChild(document.createTextNode(" "));
              childage.appendChild(h1);
              var h = document.createElement("h6");
              h.appendChild(document.createTextNode("Children Age " + (i + 1)));
              childage.appendChild(h);

              var selectList = document.createElement("select");
              selectList.setAttribute("id", "mySelect");
              selectList.setAttribute("class", "form-control");
              childage.appendChild(selectList);
              childage.appendChild(document.createElement("br"));

              //Create and append the options
              for (var j = 0; j < array.length; j++) {
              var option = document.createElement("option");
              option.setAttribute("value", array[j]);
              option.text = array[j];
              selectList.appendChild(option);
              }
              }

              }


              }



              Add numbers to your child DIVs:



               <div id="childage0" class="col-xs-1">
              </div>
              <!-- </div>
              <div class="form-group"> -->
              <div id="childage1" class="col-xs-1">
              </div>





              share|improve this answer


























                1












                1








                1







                Your second select isnt placed in right div. See what you can do:



                function addFields() {
                var number = document.getElementById("selected_childs").value;
                var childage = document.getElementById("childage0");

                //Create array of options to be added
                var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

                while (childage.hasChildNodes()) {
                childage.removeChild(childage.lastChild);
                }
                if (number == 1) {
                // statement
                for (i = 0; i < number; i++) {
                var h = document.createElement("h6");
                var h1 = document.createElement("h6");
                h1.appendChild(document.createTextNode(" "));
                childage.appendChild(h1);

                h.appendChild(document.createTextNode("Children Age " + (i + 1)));
                childage.appendChild(h);

                var selectList = document.createElement("select");
                selectList.setAttribute("id", "mySelect");
                selectList.setAttribute("class", "form-control");
                childage.appendChild(selectList);
                childage.appendChild(document.createElement("br"));

                //Create and append the options
                for (var j = 0; j < array.length; j++) {
                var option = document.createElement("option");
                option.setAttribute("value", array[j]);
                option.text = array[j];
                selectList.appendChild(option);
                }
                }
                } else {
                // statement
                for (i = 0; i < number; i++) {
                childage = document.getElementById("childage"+i);
                var h1 = document.createElement("h6");
                h1.appendChild(document.createTextNode(" "));
                childage.appendChild(h1);
                var h = document.createElement("h6");
                h.appendChild(document.createTextNode("Children Age " + (i + 1)));
                childage.appendChild(h);

                var selectList = document.createElement("select");
                selectList.setAttribute("id", "mySelect");
                selectList.setAttribute("class", "form-control");
                childage.appendChild(selectList);
                childage.appendChild(document.createElement("br"));

                //Create and append the options
                for (var j = 0; j < array.length; j++) {
                var option = document.createElement("option");
                option.setAttribute("value", array[j]);
                option.text = array[j];
                selectList.appendChild(option);
                }
                }

                }


                }



                Add numbers to your child DIVs:



                 <div id="childage0" class="col-xs-1">
                </div>
                <!-- </div>
                <div class="form-group"> -->
                <div id="childage1" class="col-xs-1">
                </div>





                share|improve this answer













                Your second select isnt placed in right div. See what you can do:



                function addFields() {
                var number = document.getElementById("selected_childs").value;
                var childage = document.getElementById("childage0");

                //Create array of options to be added
                var array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];

                while (childage.hasChildNodes()) {
                childage.removeChild(childage.lastChild);
                }
                if (number == 1) {
                // statement
                for (i = 0; i < number; i++) {
                var h = document.createElement("h6");
                var h1 = document.createElement("h6");
                h1.appendChild(document.createTextNode(" "));
                childage.appendChild(h1);

                h.appendChild(document.createTextNode("Children Age " + (i + 1)));
                childage.appendChild(h);

                var selectList = document.createElement("select");
                selectList.setAttribute("id", "mySelect");
                selectList.setAttribute("class", "form-control");
                childage.appendChild(selectList);
                childage.appendChild(document.createElement("br"));

                //Create and append the options
                for (var j = 0; j < array.length; j++) {
                var option = document.createElement("option");
                option.setAttribute("value", array[j]);
                option.text = array[j];
                selectList.appendChild(option);
                }
                }
                } else {
                // statement
                for (i = 0; i < number; i++) {
                childage = document.getElementById("childage"+i);
                var h1 = document.createElement("h6");
                h1.appendChild(document.createTextNode(" "));
                childage.appendChild(h1);
                var h = document.createElement("h6");
                h.appendChild(document.createTextNode("Children Age " + (i + 1)));
                childage.appendChild(h);

                var selectList = document.createElement("select");
                selectList.setAttribute("id", "mySelect");
                selectList.setAttribute("class", "form-control");
                childage.appendChild(selectList);
                childage.appendChild(document.createElement("br"));

                //Create and append the options
                for (var j = 0; j < array.length; j++) {
                var option = document.createElement("option");
                option.setAttribute("value", array[j]);
                option.text = array[j];
                selectList.appendChild(option);
                }
                }

                }


                }



                Add numbers to your child DIVs:



                 <div id="childage0" class="col-xs-1">
                </div>
                <!-- </div>
                <div class="form-group"> -->
                <div id="childage1" class="col-xs-1">
                </div>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 8:01









                iStepashkaiStepashka

                2826




                2826






























                    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%2f53407340%2funable-to-display-select-fields-side-by-side%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

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy