Click here to Skip to main content
11,484,640 members (60,863 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
Hi,

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.

JavaScript:

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,
Janes
Posted 21-Mar-13 22:54pm
Rate this: bad
good
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>
</select>
var sel = document.getElementById("testdropdown");
var optionValue = sel.options[sel.selectedIndex].value;
var optionText = sel.options[sel.selectedIndex].text;

o/p
optionValue = 2
optionText = Option2

So check whether your select list have the value.
  Permalink  
v2
Comments
maajanes at 22-Mar-13 7:37am
   
Same thing I did. But error occurs. Please see javascript in my post
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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');
  Permalink  

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

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 180
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 7 Sep 2013
Copyright © CodeProject, 1999-2015
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