Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The typical way I accomplish something like this is to actually store 3 different fields in the db for each of the different types of values. Then I create something like the following html:</p> <pre><code>&lt;!-- Input type selector --&gt; &lt;div class="cell variable-selector"&gt; &lt;select&gt;&lt;option ...&lt;/select&gt; &lt;/div&gt; &lt;!-- varied input --&gt; &lt;div class="cell variable show-text"&gt; &lt;div class="text"&gt;&lt;input type="textbox"&gt;&lt;/div&gt; &lt;div class="date-picker"&gt;&lt;input type="textbox" class="datepicker"&gt;&lt;/div&gt; &lt;div class="drop-down-bool"&gt;&lt;select&gt;&lt;option ...&lt;/select&gt; &lt;/div&gt; </code></pre> <p>Then I have css that hides or shows the correct input element based on which class the cell has:</p> <pre><code>div.variable div { display:none } div.show-text div.text { display: inline } div.show-date-picker div.date-picker {display: inline } div.show-drop-down-bool div.drop-down-bool {display: inline} </code></pre> <p>lastly you can setup some javascript so that when you change your variable-selector you change the class of your variable cell. Which jquery one might do this as so:</p> <pre><code>$(document).ready(function() { var variableSelector = $("div.variable-selector &gt; select"); variableSelector.change(function() { var type = $(this).text(); var class = "cell variable show-" + type; var variableCell = $(this).parent().parent().find("variable"); variableCell.attr("class", class); }) }); </code></pre> <p>As a quick warning I wrote the above code on the fly in the stack overflow editor window so there might be a couple of syntax errors or a minor bug somewhere but the basic idea should work. Hope it helps. --Adam</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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