Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

JavaScript
//For most of the dijit.form widgets, the value can be fetched by widget.get('value')
var value = dijit.byId('testdropdown').get('value');
 
Share this answer
 
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.
 
Share this answer
 
Say this is your select list :

HTML
<select id="testdropdown">
<option value="1">Option1</option>
<option value="2" selected="selected">Option2</option>
<option value="3">Option3</option>
</select>

JavaScript
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.
 
Share this answer
 
v2
Comments
maajanes 22-Mar-13 7:37am    
Same thing I did. But error occurs. Please see javascript in my post

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900