Select menu dynamic and static

I have a select menu with dynamic rows.
At the end I should enter a static value. I don’t want it to appear first, like now. It should be the last row. Is it possible?

<select id="tipofrm" class="form-control" name="tipofrm" dmx-bind:options="ricavacau.data.custom" optionvalue="cod+'^'+dfine" optiontext="desc">
                                    <option dmx-bind:value="var_date.datetime.formatDate('yyyy-MM-dd')">SPEDIRE ALLA DATA</option>
                                </select>

Could you add the option to your data and then use a sort to put it at the bottom? Something like what I did here - Tagify Group By

I tried writing some code to achieve what you want, but it persists in putting it at the top, even though normally this code would add it to the end so it seems an anomaly of Wappler.

$(document).ready(function(){

            var val = dmx.parse('var_date.datetime.formatDate(`yyyy-MM-dd`)');

            var txt = "SPEDIRE ALLA DATA";

            var sel = document.getElementById("tipofrm");

            var opt = document.createElement('option');

            opt.text = txt;

            opt.value = val;

    sel.add(opt)

})

You should be able to simply swap the order of the items in the statement. They should render in the order they appear in the code.

Can you explain what you mean?

Sorry folks, having a senior moment by the looks of it.
I recalled doing it by moving the option parameter order in the statement but i cant get this to work on the way i thought
Sorry all

Could perhaps use array management at server level to append the value to the end of the select dynamic values before returning it.

1 Like

Couldn’t just handle it on client side?

  1. Add an Array in our page
  2. On success of the serverconnect that contains the values for the select, add a flow that repeats through the serverconnect and insert the values we need to the array
  3. Outside (after the repeat) we just add the option we need to the array
  4. Set the Array as the Datasourse for the select…

yes, that would probably work as well, guess I’m just a “doing at server level when you can” sort of guy.

2 Likes