0

I want to get selected items from iccube-dropdown-widget with javascript. Drop-down-widget has Div-ID ‘icCubeDropDown’.

var t = window.document.getElementById(‘icCubeDropDown’);  

doesn’t work, t is Null. How can I do this?

Thanks in advance!

EDIT

var text = $("#w8 select.icCubeDropDown").children("option").filter(":selected").text(); var text is empty. What is wrong?

Here is my report code:

my report code

Ana B
  • 3
  • 3

1 Answers1

0

You're mixing class with id, 'icCubeDropDown' is a class. Id's in icCube are more like 'ic3-131'.

I'd be using jquery selectors

var select = $("#ic3-131 select.icCubeDropDown")

this finds the element with id ic3-131 and a select descendant.

hope it helps

ic3
  • 7,917
  • 14
  • 67
  • 115
  • Thank you, this get me closer to my solution. Pleas read my edited Question. – Ana B Mar 02 '16 at 14:33
  • ana, check http://stackoverflow.com/questions/2780566/get-selected-value-of-a-dropdowns-item-using-jquery and play a bit to see what is happening. – ic3 Mar 03 '16 at 07:55
  • Thanks! Now I figured out how I can get selected items by id, but there is another problem. Div-Ids are dynamic and changes always, so my solution doesn’t work consistently. What options do I have to solve this problem? – Ana B Mar 04 '16 at 16:11
  • you can add in the widget/box a class that is unique per id and use it for selection – ic3 Mar 04 '16 at 16:20
  • Thank you! you helped me a lot :) – Ana B Mar 07 '16 at 10:25