Hi again,

Thanks for your swift reply Demetrios. I would normally have used your
solution - iterating through the options - but in this case I have
several options without unique values, so that wont work.

Since posting my question here I've created a workaround with a little
bit of javascript and a hidden field. When I create my form I add a
hidden field that will carry the option label text content, and to the
select i add a bit of javascript to the onchange attribute:

  HiddenField modelName = new HiddenField("modelName", String.class);
  Select select = new Select("model");
  select.setAttribute("onchange",
    "this.form.modelName.value = this.options[this.selectedIndex].text;");

Thus the contents of the option will be copied to the hidden field on the
client side. As I only use the model name for presentation, it doesn't
matter too much if the user disables javascript.

-- 
Fredrik Jonson

Reply via email to