Hi there!
I’ve seen another post on here about the same subject, but it didn’t really address the issue that I’m having.
I am trying to create input fields using dynamic variables, but when I type something into the input box, the value disappears.
Below is a snippet of my code:
{% stripnewlines %}
{% assign asset_selection = "local" %}
{% assign asset = "fixed_assets" %}
{% capture proceeds %}
{{ asset_selection }}_proceeds.{{ asset }}
{% endcapture %}
{% capture base_cost %}
{{ asset_selection }}_base_cost.{{ asset }}
{% endcapture %}
{% capture number_of_transactions %}
{{ asset_selection }}_number_of_transactions.{{ asset }}
{% endcapture %}
{% capture asset_gain %}
{{ asset_selection }}_{{ asset }}_gain
{% endcapture %}
{% capture total_gain %}
total_{{ asset_selection }}_gain
{% endcapture %}
{% capture asset_loss %}
{{ asset_selection }}_{{ asset }}_loss
{% endcapture %}
{% capture total_loss %}
total_{{ asset_selection }}_loss
{% endcapture %}
{% comment %}Table Content{% endcomment %}
<table>
{% ifi INT(custom.[proceeds]) != 0 or INT(custom.[base_cost]) != 0 %}
<tr>
<td class="usr-align-center">
{% ic %}
{::infotext as="hover"}
e.g. Land, buildings, mineral rights
{:/infotext}
{% endic %}
</td>
<td>
Fixed/immoveable assets
</td>
<td>
</td>
<td class="usr-align-right">
{% input custom.[proceeds] as:currency precision:0 required:true placeholder:0 %}
</td>
<td>
</td>
<td class="usr-align-right">
{% input custom.[base_cost] as:currency precision:0 required:true placeholder:0 %}
</td>
<td>
</td>
<td class="usr-align-right">
{% if custom.[proceeds]-custom.[base_cost] > 0 %}
{% assign [asset_gain] = custom.[proceeds]-custom.[base_cost] %}
{% assign [total_gain] = [total_gain]+[asset_gain] %}
{{ [asset_gain] | currency:0 }}
{% else %}
{{ INT(0) }}
{% endif %}
</td>
<td>
</td>
<td class="usr-align-right">
{% if custom.[proceeds]-custom.[base_cost] < 0 %}
{% assign [asset_loss] = custom.[proceeds]-custom.[base_cost] %}
{% assign [total_loss] = [total_loss]+[asset_loss] %}
{{ [asset_loss] | currency:0, invert:true }}
{% else %}
{{ INT(0) }}
{% endif %}
</td>
<td>
</td>
<td class="usr-align-right">
{% input custom.[number_of_transactions] as:currency precision:0 required:true placeholder:0 %}
</td>
</tr>
{% endifi %}
</table>
{% endstripnewlines %}
This is the output after a value has been entered: