Advanced [Exercise 4: Dropdown with data from drop] (Training slides exercise)

  • Create an input table where name investor, type and amount can be entered
  • Show all investors in a dropdown

Solution:

{% stripnewlines %}
| Investors name
| Investor type
| Amount
{% newline %}
|------
|------
|------:+
{% newline %}
{% fori investor in custom.investors %}
  | {% input investor.name %}
  | {% input investor.type %}
  | {% =$3+input investor.value as:currency %}
  {% newline %}
{% endfori %}
|
|
|__^^ {{ $3 | currency }} ^^__
{% endstripnewlines %}
{% assign investor_array = "" %}
{% for investor in custom.investors %}
  {% assign investor_array = investor_array | append:investor.name %}
  {% unless forloop.last %}
    {% assign investor_array = investor_array | append:"|" %}
  {% endunless %}
{% endfor %}
{% input custom.selection.companies as:select options:investor_array %}

Solution using HTML Tables:

<table class="usr-width-100">
  <thead>
    <tr>
      <th class="usr-line-bottom"><b>Investors name</b></th>
      <th class="usr-line-bottom"><b>Investor type</b></th>
      <th class="usr-line-bottom usr-align-right"><b>Amount</b></th>
    </tr>
  </thead>
  <tbody>
    {% fori investor in custom.investors %}
      <tr>
        <td class="">{% input investor.name %}</td>
        <td class="">{% input investor.type %}</td>
        <td class="usr-align-right">{% input investor.value as:currency %}{% assign total_investor_value = total_investor_value+investor.value %}</td>
      </tr>
    {% endfori %}
    <tr>
      <td class=""></td>
      <td class=""></td>
      <td class="usr-double-line-top usr-double-line-bottom usr-align-right">{{ total_investor_value | currency }}</td>
    </tr>
  </tbody>
</table>

{% for investor in custom.investors %}
  {% assign investor_array = investor_array | append:investor.name %}
  {% unless forloop.last %}
    {% assign investor_array = investor_array | append:"|" %}
  {% endunless %}
{% endfor %}
{% input custom.selection.companies as:select options:investor_array %}