Select component returned index value, not string value

Hi,

I was using Select component of V13 in my iron-form. However, when submitting, the value of that Select component was the index of the selected item, not the item string itself. I am wondering how I can make the value of the Select component be the item label, instead of index.

Many thanks,
Joey

Joey Chen:
Hi,

I was using Select component of V13 in my iron-form. However, when submitting, the value of that Select component was the index of the selected item, not the item string itself. I am wondering how I can make the value of the Select component be the item label, instead of index.

Many thanks,
Joey

Hi.

Select<String> select = new Select<>();
select.setItems("A", "B","C");
select.addValueChangeListener((e) -> {
		Notification.show(e.getValue());
	});

It will give you selected item.

Hi,

The getValue() method did return string value. However, my issue is not on the server side, but client side. My scenario was to have a iron-form at the client side, and added textfield and select field into the iron-form. When clicking submit button, the client side would execute javascript form.submit(). I have a servlet to capture the request and parameters. However, in the servlet, the request parameter of the select field was the index value, instead of the string value. During browser debugging, I found that, at the browser console, running javascript of “document.getElementById(‘select’).value” leads to index value, not the string value. Any advices how to make the client return string, instead of index value?

Best regards,
Joey