Hi,
I am using webdropdown version: 11.2.20112.1019. I would like to retrieve value and lenght of the dropdown item(s) based upon ID and do some valildations in javascript. Can you tell me the syntax of retrieving value and length from this dropdown field.
In addition to the above query,
Can you please let me know the code snippets for the following as well:
i) How to retrieve the number of elements from a webdropdown?
ii) How to check if a webdropdown is filled with some value or not??
Thanks for your quick response. I have tried the code snippets you mentioned but still I am not able to see "0200".
i) var x = $find("webdropdownID").get_selectedItem();
alert(
'x:' + x);
Output: Object Object
The above output is not expected.
ii) var y = $find("webdropdownID").get_selectedItem().get_text();
'y:' + y)
Output: 0200 SAMPLE
Hi SunilMehta,
Here is extension of the code snippet I gave on the first post:
.....
30 //Get selected item
31 var selectedItem = dd.get_selectedItem();
32 //Get selected item's text
33 var selectedItemText = dd.get_selectedItem().get_text();
Hope that helps,
Thanks,
Thanks for the documentation.
I am facing an issue while retrieving the value from the dropdown. The problem is:
For instance, I have two values in the dropdown:
0100 TEST
0200 SAMPLE
and "0200 SAMPLE" is the current selected value.
When I use
i) $find(
"webdropdownID").get_currentValue(), it gives me "0200 SAMPLE".
ii) $find("webdropdownID").get_items().getItem(1).get_value(), it gives only "0200".
Is there a way that I can retrieve "0200" with option 1 instead of "0200 SAMPLE"?
Due to the architecture of the WebDropDown and the way it is rendered I do not believe it would be possible (and it is certainly not recommended) to access a specific item through document.all. For accessing our controls clientside I suggest that you use the exposed CSOM. I would strongly recommend that you consider using the code suggested by Todor.
A link to WebDropDown's CSOM may be found at:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.1/CLR4.0/?page=WebDropDown~Infragistics.Web.UI_namespace.html
Please let me know if you need more information.