?
Solved

Microsoft JScript runtime error: 'document.forms.0.cmbState.options' is null or not an object

Posted on 2007-10-02
3
Medium Priority
?
308 Views
Last Modified: 2012-08-13
Hi, the following code works in an aspx page when part of a <head>, but not when part of <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

var state = document.forms[0].cmbState.options[document.forms[0].cmbState.selectedIndex].text;

Can anyone help me with this ?.

Thanks in advance
0
Comment
Question by:Netlink2
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Rejojohny earned 2000 total points
ID: 20003199
try
var state = document.getElementById('<%=cmbState.clientid%>').value;
0
 
LVL 1

Author Comment

by:Netlink2
ID: 20003303
Hi Rej,
I get the error " Microsoft JScript runtime error: Object required ".
This could be because I'm running the Javascript from a .js file. Any further ideas ?.
0
 
LVL 1

Author Comment

by:Netlink2
ID: 20003459
OK, The code works (per your response) if I copy the code in to the aspx file itself. Any way I can get it running from a .js file ?.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question