JavaScript Question

I have a Dialog List which allows multiple selections. All of the selections should be stored in a target field. However, I’m finding that only the first selection is being stored.

The following JavaScript appears in the onChange event of the Dialog List.

var index;

var choices = window.document.forms[0].DialogListChoices;

var selections = window.document.forms[0].ItemsSelected;

for (index=0; index<choices.length; index++)

{

if (choices.options[index].selected)

{

selections.value = this.value + choices.options[choices.selectedIndex].text + ", ";

       }

}

For some unapparent reason, ‘this.value’ is not returning any value. I’d appreciate any suggestions on how this code might be modified to capture and store all of the selections.

Thanks.

Subject: JavaScript Question

selectedIndex only returns the first selected option. You need to iterate through the options and check .selected for each.

Subject: JavaScript Question

strtext = strval & choices.options[choices.selectedIndex].text + ", ";

strval = strval & choices.options[choices.selectedIndex].value + ", ";

am not having idea what type of selection field in case text field means u can store values in

selection.value = strtext (or) strval

Subject: RE: JavaScript Question

The following gives the intended results:

var index;

var choices = window.document.forms[0].Choices;

var selections = window.document.forms[0].Selected;

selections.value = “”;

for (index=0; index<choices.length; index++)

{

if (choices.options[index].selected)

{

selections.value += choices.options[index].text + "\r";

       }

}

Thanks.