Select control value property in repeat doesn't work

I have a select control in a repeat with this expression:
dmx-on:changed="dd_products.select(value);inp_UnitPrice1.setValue(dd_products.data.UnitPrice)"

And it doesn’t work. If I change ‘value’ inside the parenthesis to a hard-code value (i.e 10 or 14, etc) it works for that value.

This works:
dmx-on:changed="dd_products.select(10);inp_UnitPrice1.setValue(dd_products.data.UnitPrice)"
Any ideas why this isn’t working or what the correct expression should be?

What is value and where does it come from?

It’s what the builder puts there when I define the on click event.

The full select is:

<select class="form-select" id="inp_ProductID" name="ProductID" dmx-bind:id="insp_ProductID_{{$index}}" dmx-bind:aria-describedby="insp_ProductID_{{$index}}_help" dmx-bind:name="OrderDetails[{{$index}}][ProductID]" aria-describedby="inp_ProductID_help" placeholder="Enter Product" dmx-bind:value="ProductID" dmx-bind:options="sc_products.data.Products" optiontext="ProductName" optionvalue="ProductID" dmx-on:changed="dd_products.select(value);inp_UnitPrice.setValue(dd_products.data.UnitPrice)"><option value="">Select Product</option>

This is the selection from the builder:
image

What are you doing on this page exactly? What are you trying to achieve?

I’m wanting the UnitPrice to be filled in when the user selects a product.

I have a Data Detail that has a data source from the Products server connect and the key is the ProductID. This should correspond to the ProductID from the dropdown. If I hard code the value in, it works as expected, it’s just not picking up the correct value from the control.

The odd thing is if I use the value to set the field directly, it works. Obviously, its the ID and not the UnitPrice, but shows the value is correct.

This works:
dmx-on:changed="inp_UnitPrice.setValue(value)"

And this works:
dmx-on:changed="dd_products.select(1)"

But this doesn’t work:
dmx-on:changed="dd_products.select(value)"

The select value is always a string. It needs to be converted to number.
Example:

dmx-on:changed="dd_products.select(value.toNumber())

Just apply it using the data formatter, so the formatter js can be added on the page.

Ahh, that makes sense. I didn’t think about data types, but that explains why hard coding the value works.

Thanks for your help. Works great now.

1 Like