Use the size attribute which takes the number of items you want to display and set it to the number of options you have (6) in order to get the full list view. Since you only want to allow 1 item to be selected, also remove the attribute multiple from the select element.

<select name="pets" size=6>
  <option>dog</option>
  <option>cat</option>
  <option>hamster</option>
  <option>bird</option>
  <option>donkey</option>
  <option>fish</option>
</select>

Check mdn for more information about the available attributes for the select element.

Answer from Victor Santizo on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ html โ€บ html_lists.asp
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_list_grid_view.asp
How To Create a List Grid View
Fullscreen Video Modal Boxes Delete Modal Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Color Picker Email Field Tooltips Display Element Hover Popups Collapsible Calendar HTML Includes To Do List Loaders Badges Star Rating User Rating Overlay Effect Contact Chips Cards Flip Card Profile Card Product Card Alerts Callout Notes Labels Ribbon Tag Cloud Circles Style HR Coupon List Group List Group with Badges List Without Bullets Responsive Text Cutout Text Glowing Text Fixed Footer Sticky Element Equal Height Clearfix Responsive Floats Snackbar Fullscreen Window Scroll Drawing
Top answer
1 of 3
2

Use the size attribute which takes the number of items you want to display and set it to the number of options you have (6) in order to get the full list view. Since you only want to allow 1 item to be selected, also remove the attribute multiple from the select element.

<select name="pets" size=6>
  <option>dog</option>
  <option>cat</option>
  <option>hamster</option>
  <option>bird</option>
  <option>donkey</option>
  <option>fish</option>
</select>

Check mdn for more information about the available attributes for the select element.

2 of 3
2

You can make the <select> 100% of the height of the <form> that contains it. See this fiddle for an example of a div enclosing a form, with a select filling the height of the form.

This starts with a simple structure, just enough that the form is enclosed in something so you can see the relative layout.

    <div>
        <form>
        <select id="thelist" name="pets" size="6">
        <option value="1">dog</option>
        <option value="2">cat</option>
        <option value="3">hamster</option>
        <option value="4">bird</option>
        <option value="5">donkey</option>
        <option value="6">fish</option>
        </select>
        </form>
    </div>

I give the div a height, a background so you can see it, and padding so it's content doesn't naturally cover it. Make the form any height you want, including 100% of the div. I made it 90% so you can still see the enclosing div. Notice the form's width fills the div width except for the padding.

You can then just set the height of the select list to anything you want inside the form. Here's my CSS

div {
    background-color: #fff0f0;
    height: 40em;
    padding: 1.5em 1.5em 0 1.5em;
}
form {
    background-color: #f0f0f0;
    height: 90%;
}
#thelist {
    height: 100%;
}

Put together as a snippet, and making it smaller to fit better here...

div {
    background-color: #fff0f0;
    height: 20em;
    padding: 1.5em 1.5em 0 1.5em;
}
form {
    background-color: #f0f0f0;
    height: 40%;
}
#thelist {
    height: 100%;
}
<div>
    <form>
        <select id="thelist" name="pets" size="6">
            <option value="1">dog</option>
            <option value="2">cat</option>
            <option value="3">hamster</option>
            <option value="4">bird</option>
            <option value="5">donkey</option>
            <option value="6">fish</option>
        </select>
    </form>
</div>

๐ŸŒ
Shay Howe
learn.shayhowe.com โ€บ html-css โ€บ creating-lists
Creating Lists - Learn to Code HTML & CSS
HTML provides unordered, ordered, and definition lists all of which can be stylized using CSS. Learn how.
๐ŸŒ
Mobiscroll
demo.mobiscroll.com โ€บ javascript โ€บ listview
Javascript Listview Examples | Mobiscroll
Javascript Listview demo with load more button for loading additional items from a REST service. Get and display records from JSON. Plain JS api for usage everywhere. ... Build a two pane master-detail view with the help of the listview. Use the grid layout to set up the two columns - left side for a list of names, right side for showing the details.
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ tryit.asp
List View or Grid View
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
jQuery Mobile
demos.jquerymobile.com โ€บ 1.1.2 โ€บ docs โ€บ lists โ€บ docs-lists.html
jQuery Mobile Docs - Lists Overview
<ul data-role="listview"> <li><a href="acura.html">Acura</a></li> <li><a href="audi.html">Audi</a></li> <li><a href="bmw.html">BMW</a></li> </ul> Basic list example
๐ŸŒ
Jquerymobile
api.jquerymobile.com โ€บ listview
Listview Widget | jQuery Mobile API Documentation
When you tap on the list item, ... the new page in the DOM, then kick off a page transition. View the data- attribute reference to see all the possible attributes you can add to listviews. Here is the HTML markup for a basic linked list....
Find elsewhere
Top answer
1 of 2
2

Let see what your code is doing:

// loop x3
for(n=0;n<3;n++){

// you create new element LI in li
var li = document.createElement("li");

// you get WRAPPPER instance in er
// what is WRAPPER? you have only one?
var er = document.getElementById('wrapper'); 

// you add er (child) to li (parent), this is what you want?
// qw is nothing, appendchild will return nothing
var qw = li.appendChild(er);

// you add qw (you mean WRAPPER?) to LIST x3 times, maybe you want to do this only 1 time
document.getElementById('list').appendChild(qw);
}

now, this should be your solution

var er = document.getElementById('wrapper'); 
for(n=0;n<3;n++){
  var li = document.createElement("li");
  er.appendChild(li);
}
document.getElementById('list').appendChild(er);

or, in case you need a wrapper per element

for(n=0;n<3;n++){
  var li = document.createElement("li");
  var wr = document.createElement("div");
  li.appendChild(wr);
  document.getElementById('list').appendChild(li);
}

or, if wrapper is one and you want to clone it:

var er = document.getElementById('wrapper'); 
for(n=0;n<3;n++){
  var li = document.createElement("li");
  li.appendChild(er.cloneNode());
  document.getElementById('list').appendChild(li);
}
2 of 2
1

Edit3: To hide your div not created from your loop simply wrap your div with another wrapper (that has display: none;) like so:

<div style="display: none">
    <div id="wrapper">
        <input name="num" type="button" class="btn1" id="num" value="1" />
        <div id="from">From:</div>
        <div id="startcity"></div>
        <div id="to">To:</div>
        <div id="finalcity"></div>
    </div>
</div>

Notice that if you add "display: none" to your actual wrapper then the divs created with your loop won't be displayed. This is because .cloneNode also clones the style.

Edit2:

You are using position: absolute; and setting the position of each of these elements on top of one another. This also shows that you are using the same id multiple times... which you should avoid. id's should be unique.

#apo {
    position: absolute;
    width: 39px;
    height: 23px;
    z-index: 1;
    left: 126px;
    top: 34px;
}
#startpoli {
    position: absolute;
    width: 200px;
    height: 37px;
    z-index: 2;
    left: 213px;
    top: 19px;
    background-color: #98d0d2;
}
#pros {
    position: absolute;
    width: 48px;
    height: 25px;
    z-index: 3;
    left: 122px;
    top: 74px;
}
#finalpoli {
    position: absolute;
    width: 200px;
    height: 37px;
    z-index: 4;
    left: 213px;
    top: 69px;
    background-color: #c6d298;
}

This is the result when I remove some of your css causing the problems:

Here is the modified css for the image on top:

#wrapper {
    background-color: #e5e4e2;
    height: 200px;
    width: 600px;
    padding: 5px;
    font-family: Georgia, "Times New Roman", Times, serif;
}

.btn1{
    background-color: #CAC9DB;
    width: 40px;
    height: 40px;
    font-size: 24px;
    font-weight: bold;
    padding: 5px;
    display: inline-block;
    }
#apo {
    text-align: justify;
    vertical-align: top;
    display: inline;
    margin-top: -10px;
}
#startpoli {
}
#apo {

    width: 39px;
    height: 23px;

}
#startpoli {
    width: 200px;
    height: 37px;
    background-color: #98d0d2;
}
#pros {

    width: 48px;
    height: 25px;

}
#finalpoli {

    width: 200px;
    height: 37px;

    background-color: #c6d298;
}

Edit: It seems that the wrapper doesn't allow itself to be added to multiple elements at the same time. So just clone ( with .cloneNode(true) ) the original er

li.appendChild(er) doesn't return an element last I checked. Just append li to your list instead of qw

var er = document.getElementById('wrapper'); 
for(var n=0;n<3;n++){
  var li = document.createElement("li");
  li.appendChild(er.cloneNode(true)); //clone original wrapper and add it to your li
  document.getElementById('list').appendChild(li); //add li to your list
}

Demo

๐ŸŒ
DHTMLX
dhtmlx.com โ€บ docs โ€บ products โ€บ dhtmlxList
JavaScript ListView UI Control - dhtmlxList
JavaScript ListView is a list control for displaying and manipultating items in a customizable list with dynamic rendering.
๐ŸŒ
SitePoint
sitepoint.com โ€บ html & css
List view need help - HTML & CSS - SitePoint Forums | Web Development & Design Community
April 16, 2021 - .myRow .list-view .panel-body .price_m { grid-area: price; } That puts the price div over to the top right even though the html was nowhere near there. Thatโ€™s the beauty of CSS grid as you can drop content into specified places without removing it from the flow as such.
๐ŸŒ
Buildfire
sdk.buildfire.com โ€บ listview
ListView | Buildfire Developer Docs
let listView = new buildfire.components.listView("#listViewContainer", { settings: { itemImage: 'square', contentMapping: { titleKey: 'data.title', subtitleKey: 'data.subtitle', imageKey: 'data.imageUrl', descriptionKey: 'data.description', }, customListAction: { html: `<i class="material-icons">chevron_right</i>`, } } }); listView.onDataRequest = (event, callback) => { getData(event.searchValue, (result) => { callback(result); }); } listView.onItemClick = event => { if(event.target === 'action') { //do something } }
๐ŸŒ
Framework7
framework7.io โ€บ docs โ€บ list-view
List View (Table View) | Framework7 Documentation
A list view presents data in a scrollable list of multiple rows that may be divided into sections/groups.
๐ŸŒ
CodePen
codepen.io โ€บ magnusb โ€บ pen โ€บ xRdNXg
List view / grid view
<div class="filter-buttons"> <div class="list-view-button"><i class="fa fa-bars" aria-hidden="true"></i> List view</div> <div class="grid-view-button"><i class="fa fa-th-large" aria-hidden="true"></i> Grid view</div> </div> <ol class="list list-view-filter"> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> <li>List item 4</li> <li>List item 5</li> <li>List item 6</li> </ol>
๐ŸŒ
Syncfusion
syncfusion.com โ€บ javascript โ€บ listview
JavaScript ListView | Multilevel ListView With Images | Syncfusion
JavaScript ListView control displays data in a list-like interface and supports templating, sorting, grouping, and more features.
๐ŸŒ
Telerik
telerik.com โ€บ controls โ€บ listview โ€บ appearance and styling โ€บ html output and css styling
Telerik Web Forms ListView Appearance and Styling HTML Output and CSS Styling - Telerik UI for ASP.NET AJAX
The Unordered and Ordered List layouts present the RadListView data in the respective HTML elements - <ul> or <ol>. Each data item is represented by a list item - <li>.
๐ŸŒ
Daily Dev Tips
daily-dev-tips.com โ€บ posts โ€บ css-grid-list-view-toggle
CSS Grid/List view Toggle Tutorial [2022]
May 7, 2020 - We are adding eventListeners on our buttons and add or remove the list class from our wrapper element. So with this code you add or remove the class from the wrapper element. Therefore you can switch between the multi-column view (grid) to the list view.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ HTML โ€บ Reference โ€บ Elements โ€บ li
<li>: The List Item element - HTML - MDN Web Docs - Mozilla
The <li> HTML element is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>). In menus and unordered lists, list items are usually displayed using bullet points.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Learn_web_development โ€บ Core โ€บ Structuring_content โ€บ Lists
Lists - Learn web development | MDN
You can find an example of the correct HTML for this example at text-complete.html in our GitHub repo. It is perfectly OK to nest one list inside another one. You might want to have some sub-bullets sitting below a top-level bullet.