Click here to Skip to main content
11,922,789 members (48,871 online)
Rate this:
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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.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