Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple values for <options> in <select> list HTML
    primarykey
    data
    text
    <p>I'm having a little trouble attacking this problem and wondered if anyone could push me in the right direction. What I would like to do is have a list that's have two components, a label and value. So in essence I would like a list that looks like a table with the ability to scroll up and down (since my size is preset and I have to display all the values), I'm just not sure how to approach it. </p> <p>My first approach was just to embed a table with all my values inside of a div with overflow:scroll. Which was great until I brought it into Mobile Opera, where overflow doesn't work. </p> <p>For a quick fix I threw my labels and values into separate select lists, which does work and look good. Except I don't want to have to scroll them independently, i.e. the labels weren't matching their values if I scrolled one and not the other. </p> <p>A quick and dirty approach I have now is just combining them as strings into a single option, but it does not really look good and I would ideally like to text-align:left / text-align:right for better viewing. </p> <p>What I have so far:</p> <pre><code> var statusVarLabel = ["label 1","label 2","label 3","label 4","label 5","label 6","label 7","label 8","label 9","label 10","label 11","label 12","label 13","label 14","label 15","label 16","label 17","label 18","label 19","label 20"]; var statusVarInfo = ["variable 1","variable 2","variable 3","variable 4","variable 5","variable 6","variable 7","variable 8","variable 9","variable 10","variable 11","variable 12","variable 13","variable 14","variable 15","variable 16","variable 17","variable 18","variable 19","variable 20"]; function getStatus(){ var varContainer = document.getElementById("varContainer"); varContainer.size = statusVarLabel.length; tabSpacing = 0; for (var i=0; i &lt; statusVarLabel.length; i++) { if (tabSpacing &lt; statusVarInfo[i].length) tabSpacing = statusVarInfo[i].length; }; for (var i=0; i &lt; statusVarLabel.length; i++) { var check = 0; for (var j=0; j &lt; varContainer.length; j++) { if ( statusVarLabel[i] == varContainer.options[j].text.slice(0,statusVarLabel[i].length)){ check = 1; break; } }; var stringSpacing = ""; for (var k=0; k &lt; (tabSpacing-statusVarInfo[i].length)+5; k++) { stringSpacing = stringSpacing + " "; }; if (check == 0) addOption(varContainer, statusVarLabel[i] + stringSpacing + statusVarInfo[i], i); }; } </code></pre> <p>Just wondering if anyone out there has run into the same problem. I'm still a bit new to the HTML game, is there a way to embed a table or div within a list?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload