wix code - Dropdown list returns value as guid and not string.

export function dropdown1_change(event, $w) {

var suburb = $w(‘#dropdown1’).value;

//this returns a guid similar to xxxx-xxxx-xxxx-xxxx, the dropdown is displaying the text correctly. It’s getting its list items from a referenced database.
I want to text value so i can match against a string for eg…

wixData.query(“Locations”)
.eq(“suburb”, suburb)

if i am approaching this wrong perhaps i should use a different approach?

oh suburb is the primary key if that helps

this is the referenced collection, i have to use a dropdown control as textboxes wont read the reference field

ok, through the console log i found that my dropdown value is the id and the label is the text displayed just like c#, so is this a databinding? I tried to find a label property and text and neither exist. Is there a get the text value from the id in the databse?

Hey mate,

If im reading it right, you just want to get the label of the dropdowns selected item rather than the value correct?

If so you can use dropdown options and selected index to find it, see below

let index = $w(“#dropdown1”).selectedIndex; // Get the selected index
let itemOptions = $w(“#dropdown1”).options[index] // get the selected item
let itemLabel = itemOptions.label; // grab the label of selected object
let itemValue = itemOptions.value; // grab the value of selected object

console.log("Label = " + itemLabel) // the label of the selected dropdown item 
console.log("Value = " + itemValue) // the value of the selected dropdown item

Thanx for your assistence it is greatly appreciated. Hammer on the proverbial.

Hi @nikmulconrayarchitec ,

Would you be willing to share the full code so it would be possible to see the way it is implemented?
Cheers!

Very useful thanks