Get TEXT of Select HTML Control

Hi,
I need to show the TEXT part of selected item in a Select HTML control. I only see option to fetch the Value part in data bindings UI:

image

Is it possible to get the text part?

Is this field in the bank? this column ex: title,

If you do not have it, you use join

This is not server connect. Its a simple Select HTML control, with text & value.

<select id="selectSenderCountry">...<option value="10">Hello</option>....</select>

On setting selectSenderCountry.value in data binding, 10 is shown. Instead I need to show the text part, i.e., Hello,

Could not find any option to get the TEXT part of Select HTML control.
So, used the current index of select control as index of server connect query to get field directly.

Server Connect: serverconnectCountry
Select Control: selectSenderCountry
Text Input: inputCountry

inputCountry.setValue(serverconnectCountry.data.query1[selectSenderCountry.selectedIndex].countryName)

If any one finds a way to get the TEXT part when there is no server connect data, please share.

2 Likes

Hi @nshkrsh,

Did you ever find a better way than this to get the TEXT part of a SELECT component?

It seems excessive to have to use a sever connect query, but i can’t find a better way?

So if anyone else reads this, i found a JS solutions which may be better (performance wise) than running a SC query.

I created a simple function that I then run when the value of the SELECT element changes:

function teamText() {
    var text = document.getElementById("sel_team").selectedOptions[0].text;
    dmx.app.set('teamText', text)
}

I then simply bind teamText to a variable component in App Connect and use that as per normal to display in my app.

1 Like

we didn’t find a better solution. your script looks good to handle it.