Skip to Content
avatar image
Former Member

Set initial selected value in dropdown list

Hi guys!

A really frequent asked question but I didn't find my answer in all posts around it.

I need to set initial value selected in a dropdown list amoung all entry in this list.

For tis i used context mapping with a 0,n node. I get all my values in the list. I also have a single attribute that hold the initial value to compare with and I wrote the following script at form:ready event of my listbox :

this.selectedIndex = -1;
for (var i = 0; i < this.length; i++)
if (this.getSaveItem(i) == $record.attr1.value)
	this.setItemState(i,true) = i;

And of course nothing happens (or it wouldn't be fun...)!!

Really need your help to get the default selecteded value back from db data.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 25, 2010 at 07:12 PM

    With Enumerated Drop-down List from WD library the first value should be selected by default.

    Also setItemState works for Listbox and for DropdownList, you will need to write as

    this.selectedIndex  = 0

    Also check out JS code to loop all elements for a drop-down in this [wiki|]

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member


      In fact that was a problem of binding... I need to bind elements to my 0,n node which contains all values but store the result (link binding) in a 0,1 attribute and then all is working fine.

      Double binding : one for the value list the second to result attribute. I've never understood that point from all example i saw... I'm going to check if i need to change my glasses... 🤪