Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
I am using dojo filteringselect control and bind the values from DB. I want to do a validation in javascript and want to take the selected value. When I am doing this I got an error
''options' is null or not an object'. Kindly help to overcome this issue and below is the javascript and aspx code.
var sel = document.getElementById("testdropdown");
var str1Try = sel.options[sel.selectedIndex].value;

<select dojotype="dijit.form.FilteringSelect" autocomplete="true" id="testdropdown" name="testdropdown" style="width: 200px;" runat="server">
Thanks in advance,
Posted 21-Mar-13 22:54pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Say this is your select list :
<select id="testdropdown">
<option value="1">Option1</option>
<option value="2" selected="selected">Option2</option>
<option value="3">Option3</option>
var sel = document.getElementById("testdropdown");
var optionValue = sel.options[sel.selectedIndex].value;
var optionText = sel.options[sel.selectedIndex].text;
optionValue = 2
optionText = Option2
So check whether your select list have the value.
maajanes at 22-Mar-13 7:37am
Same thing I did. But error occurs. Please see javascript in my post
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I don't know which explorer you using but, in IE if you provide the same name for "id" and "name" attribute , then it through that type of error.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

//For most of the dijit.form widgets, the value can be fetched by widget.get('value')
var value = dijit.byId('testdropdown').get('value');

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 375
1 Sergey Alexandrovich Kryukov 329
2 CPallini 260
3 DamithSL 214
4 Maciej Los 197
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115

Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 7 Sep 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100