Reputation: 7
I have the following code for a checklist inside a ComboBox:
<sq8:ComboBox runat="server" ID="ComboBox1" CheckBoxes="True" CheckedItemsTexts="DisplayAllInInput" Width="340px" OnClientItemChecked="ShowAlert"><Items>
<sq8:ComboBoxItem runat="server" Value="Yes" Text="Yes"></sq8:ComboBoxItem>
<sq8:ComboBoxItem runat="server" Value="No" Text="No"></sq8:ComboBoxItem>
<sq8:ComboBoxItem runat="server" Value="Maybe" Text="Maybe"></sq8:ComboBoxItem>
</Items>
</sq8:ComboBox>
<sq:BindableControl runat="server" TargetControlID="ComboBox1" DataField="ComboBox1"></sq:BindableControl>
I have the following simple JavaScript to get the checkeditems, in an alert:
<script type="text/javascript">
function ShowAlert() {
var combobox = $findByControlId("ComboBox1").get_checkedItems();
alert(combobox);
}
</script>
I added the function to the OnClientItemChecked property on the ComboBox but when I test this, the alert shows the values as:
[object Object]
I tried adding ".ToString" to the end of the alert:
alert(combobox.ToString);
This then showed the checkeditems as "undefined" instead of "[object Object]"
I'm a bit lost. Could anyone help? The datatype for the ComboBox in my datamodel is String. Should it be something else?
Thanks!
Upvotes: 0
Views: 123
Reputation: 15
Try: var combobox = $findByControlId("ComboBox1").get_checkedItems().get_text());
Upvotes: 0