:: Forum >>

Return values from checked list

I'm not getting the checked values returned when the form is submitted. I get the control name from obj.setName, but not the value.

var d011001 = new AW.UI.CheckedList;
d011001.setId("d011001");
d011001.setName("d011001");
d011001.setItemText(["Mother","Father","Sister","Brother","Gfather","Gmother"]);
d011001.setItemCount(6);
d011001.setSelectedItems([]);
d011001.setClass("flow","horizontal");
page1.setContent("d011001",d011001.toString());

I'm missing something basic here. Any assistance is appreciated!
Myshka
Friday, July 18, 2008
http://www.activewidgets.com/javascript.forum.22347.4/how-to-get-value-from.html

For lists (AW.UI.List, AW.UI.CheckedList, AW.UI.Radio) you have to specify what is 'control value' and also make sure the hidden input tag is updated -

List:
// set control value when list item is selected
obj.onSelectedItemsChanged = function(items){
this.setControlValue(items.join(","));
}

// update hidden input tag - 'data' element
obj.onControlValueChanged = function(){
this.getContent("data").refresh();
}


Radio:
// set control value when list item is selected
radio.onSelectedItemsChanged = function(items){
var index = items[0]; // assume there is one selected item
var value = this.getItemValue(index);
this.setControlValue(value);
}

// update hidden input tag - 'data' element
radio.onControlValueChanged = function(){
this.getContent("data").refresh();
}
Alex (ActiveWidgets)
Friday, July 18, 2008
Thanks so far.

I presume that I must create a hidden input field to return the values? This is not totally clear in the documentation. Normally, the return values are a property of the control object itself.

Is "data" referring to some external hidden input such as a hidden text field OR is it a property of the content within the radio.Control.Value?
Myshka
Friday, July 18, 2008
>> I must create a hidden input field to return the values

No, each control already creates hidden 'data' element as soon as you call setName() method, and it is updated with getContent("data").refresh().
Alex (ActiveWidgets)
Friday, July 18, 2008

This topic is archived.


Back to support forum

Forum search