How to include Dynamic data in return confirm on submit

Hi,

I have a form where a pop-up on submit confirmation box appears, and wondering how do I include dynamic data from the server connect. I tried {{dynamic_field_name}}, but that didn’t work.

<form is="dmx-serverconnect-form" id="sc_frm_booking_del" method="post" action="../dmxConnect/api/orders/test" onsubmit="return confirm('Are you sure you want to cancel your Order#{{__INSERT_DYNAMIC_ORDER_NUMBER}}?');">

<form is="dmx-serverconnect-form" id="sc_frm_booking_del" method="post" action="../dmxConnect/api/orders/test" onsubmit="return confirm('Are you sure you want to cancel your Order#' + __INSERT_DYNAMIC_ORDER_NUMBER + '?')">

No need for double curly brackets… Just close the single quotes before the dynamic value and use + to add the dynamic value.

*Are you sure that “__INSERT_DYNAMIC_ORDER_NUMBER” contains your value?
What kind of element is this? Is this an input, a query field or what? Where is that coming from?

Can’t get it to work. Its a simply dynamic data from a server connect like what you use when using Dynamic Data picker

I tried this code

onsubmit="return confirm('Are you sure you want to remove ' + ordpck_pck_name + ' from your Booking?');"

show me this ordpck_pck_name on tour page…

Screenshot

Its just from a dynamic picker from a server connect for example {{ordpck_pck_name }} but I can’t incorporate it in this onsubmit="return confirm… because is non-wappler code

Is this a serverConnect field?

xxxxxx.data. ordpck_pck_name

yes its a server connect field. and I want to incorporate it into the code below

onsubmit="return confirm('Are you sure you want to cancel your Order# ServerConnectField '?')"

then… PREFIX the name of the serverconnect my friend…

What is the name of the serverconnect that ordpck_pck_name is coming from?

SHOW ME A SCREENSHOT PLEASE

The server connect name si: sc_ordetails

this is a field an array inside a repeat coming from your serverconnect…

You lost me now!

Can you show me your form on browser so I can understand your ?

I would guess that you want to use the ord_id field of your query_order :

For getting serverConnect values you need dmx.parse(‘your_serverConnect_field’)

This is what works for me:

onsubmit="return confirm('Are you sure you want to cancel your Order#'+ dmx.parse('srvc_getOrger.data.qr_GetOrder.ord_id') +'?')"

And the serverConnect with the ord_id:

Your case is confusing me because you submit a form and ask for a confirmation "sure you want to cancel your order?). And you want to pass a subquery field of your serverconnect as an identifier

I have to understand what you are trying to do my friend

Ye that is correct, I am trying to include a subquery field from the server connect and I have a form inside the repeat.
I tried your suggestion and it returns the same first record for each record display.

I have read in a previous post from you and I think that you have a custom query, right?
Custom queries return always an array of records even if it returns only 1 record.
So, I suppose you have to use $index
serverConnect[$index].ordpck_pck_name (or something like that)

Please try it and tell me

This is what I tried. The form is within a repeat.
I can’t seem to get it to work

Are you sure you want to remove '+ dmx.parse('sc_orddetail.data.repeat.query_pckages[$index].ordpck_pck_name') +' from your Booking?'

Can you please paste your code here?
The whole repeat with form inside it

<div class="row row-cols-1" id="ord_details" is="dmx-repeat" dmx-bind:repeat="sc_orddetail.data.repeat[0].query_pckages">
                  <div class="mb-3 ps-4 pe-2 col-12 col-lg-6 col-md-8 col-sm-10">
                    <div class="card w-100">
                      <div class="card-body">
                        <h5 dmx-class:text-secondary="sc_orddetail.data.query_order.ord_status==2" class="mt-1">
                          <span class="btn btn-primary btn-not-clickable position-relative" dmx-class:btn-secondary="sc_orddetail.data.query_order.ord_status==0">
                            {{ordpck_pck_name}}
                            <span class="position-absolute top-0 start-100 ms-2 translate-middle badge rounded-pill bg-danger small">
                              {{ordpck_site_abbrv}}


                            </span>
                          </span>
                          <form is="dmx-serverconnect-form" id="frm_delete_ord_pck" method="post" action="../dmxConnect/api/orders/order_package_remove.php" dmx-generator="bootstrap5" dmx-form-type="horizontal" onsubmit="return confirm('Are you sure you want to removefrom your Booking?');" dmx-on:success="sc_orddetail.load({},true);notifies1.success('Packaged successfully removed from Order.')">
                            <input type="hidden" class="form-control" id="inp_ordpck_pubid" name="ordpck_pubid" aria-describedby="inp_ordpck_pubid_help" placeholder="Enter Ordpck pubid" dmx-bind:value="ordpck_pubid">


                            <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-yellow small" dmx-show="sc_orddetail.data.query_order.ord_status==1&amp;&amp;sc_orddetail.data.event_days&gt;2">
                              <i class="far fa-trash-alt" dmx-on:click="frm_delete_ord_pck.submit()"></i>

                            </span>
                          </form>
                        </h5>
                        <p class="formatted-text" dmx-class:text-secondary="sc_orddetail.data.query_order.ord_status==2">{{ordpck_itm_description}}</p>
                      </div>
                    </div>


                  </div>
                </div>

sc_orddetail.data.repeat[0].query_pckages[$index].ordpck_pck_name

Adding the following gives me undefined:. Do I have the ( + ’ all correct? Not sure if I wrapped in the code properly??

onsubmit="return confirm('Are you sure you want to remove '+ dmx.parse('sc_orddetail.data.repeat[0].query_pckages[$index].ordpck_pck_name') +' from your Booking?');"

I have just added a hidden input, bind to it the ordpck_pck_name and used this input to display inside the confirm alert

first make a copy of your file and then replace the code you sent me with this:

<div class="row row-cols-1" id="ord_details" is="dmx-repeat" dmx-bind:repeat="sc_orddetail.data.repeat[0].query_pckages">
                    <div class="mb-3 ps-4 pe-2 col-12 col-lg-6 col-md-8 col-sm-10">
                        <div class="card w-100">
                            <div class="card-body">
                                <h5 dmx-class:text-secondary="sc_orddetail.data.query_order.ord_status==2" class="mt-1">
                                    <span class="btn btn-primary btn-not-clickable position-relative" dmx-class:btn-secondary="sc_orddetail.data.query_order.ord_status==0">
                                        {{ordpck_pck_name}}
                                        <span class="position-absolute top-0 start-100 ms-2 translate-middle badge rounded-pill bg-danger small">
                                            {{ordpck_site_abbrv}}
                                        </span>
                                    </span>
                                    <form is="dmx-serverconnect-form" id="frm_delete_ord_pck" method="post" action="../dmxConnect/api/orders/order_package_remove.php" dmx-generator="bootstrap5" dmx-form-type="horizontal" onsubmit="return confirm('Are you sure you want to remove ' + inp_ordpck_pck_name.value + ' from your Booking?');" dmx-on:success="sc_orddetail.load({},true);notifies1.success('Packaged successfully removed from Order.')">
                                        <input type="hidden" class="form-control" id="inp_ordpck_pubid" name="ordpck_pubid" aria-describedby="inp_ordpck_pubid_help" placeholder="Enter Ordpck pubid" dmx-bind:value="ordpck_pubid">                                       

                                        <input type="hidden" class="form-control" id="inp_ordpck_pck_name" dmx-bind:value="ordpck_pck_name">
                                        <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-yellow small" dmx-show="sc_orddetail.data.query_order.ord_status==1&amp;&amp;sc_orddetail.data.event_days&gt;2">
                                            <i class="far fa-trash-alt" dmx-on:click="frm_delete_ord_pck.submit()"></i>
                                        </span>
                                    </form>
                                </h5>
                                <p class="formatted-text" dmx-class:text-secondary="sc_orddetail.data.query_order.ord_status==2">{{ordpck_itm_description}}</p>
                            </div>
                        </div>
                    </div>
                </div>

Please try and tell me

Notes:

  1. There must be errors in your console… You must use dynamic ids for your elements inside the repeat (form, inputs… etc)

I am struggling with dynamic IDs, not Sur ehow to do it.
I pasted the code, and it still came back undefined