•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,845 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 451 | Replies: 1
![]() |
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Please, anyone, tell me how can this be:
Here is code that DOES work:
When I run this in IE 7.0 (which has the wonderful feature of displaying all JavaScript errors in a pop-up message), it gives me the error
"Object expected" at:
if (cust_state == "XX") {
Which makes NO SENSE because I just used that variable, and it displayed the value I entered! Moreover, there is no reason why it shouldn't work, since I'm getting the value properly, etc.
I've quadruple checked everything, about 20 times! I can't find out what's wrong here. I tried changing the name from field[6] to dropdown_1, then to dropdown_a just to eliminate some possibilities. BTW, field[1] through field[12] works fine with textboxes -- but though I could grab the value using field[13], I started having problems with this missing object error.
I even compared it to code that DOES STILL WORK and everything is the same! It's like the same code is working differently in 2 different files. Totally insane.
If anyone could help, I'd be most grateful.
Matthew
var cust_state = document.forms.info.dropdown_a.value;
// Displays "TX" or whatever state was selected. I tried removing this line; it doesn't help.
alert("State: " + cust_state);
if (cust_state == "XX") {
eval('document.forms.info.dropdown_a.style.backgroundColor = "#FFCCCC";');
eval('document.forms.info.dropdown_a.focus();');
alert("Please select a State from the drop-down box.");
return false;
}
else {
eval('document.forms.info.dropdown_a.style.backgroundColor = "#FFFFFF";');
}Here is code that DOES work:
var cust_state = document.forms.info.cust_state.value;
if (cust_state == "XX") {
eval('document.forms.info.cust_state.style.backgroundColor = "#FFCCCC";');
eval('document.forms.info.cust_state.focus();');
alert("Please select a State from the drop-down box.");
return false;
}
else {
eval('document.forms.info.cust_state.style.backgroundColor = "#FFFFFF";');
}When I run this in IE 7.0 (which has the wonderful feature of displaying all JavaScript errors in a pop-up message), it gives me the error
"Object expected" at:
if (cust_state == "XX") {
Which makes NO SENSE because I just used that variable, and it displayed the value I entered! Moreover, there is no reason why it shouldn't work, since I'm getting the value properly, etc.
I've quadruple checked everything, about 20 times! I can't find out what's wrong here. I tried changing the name from field[6] to dropdown_1, then to dropdown_a just to eliminate some possibilities. BTW, field[1] through field[12] works fine with textboxes -- but though I could grab the value using field[13], I started having problems with this missing object error.
I even compared it to code that DOES STILL WORK and everything is the same! It's like the same code is working differently in 2 different files. Totally insane.
If anyone could help, I'd be most grateful.
Matthew
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Similar Threads
- using Lua's pair() (Python)
- Error 'not all code paths return a value' (C#)
- This is the only thing i have not been able to get rid of... Tricky virus or trojan (Viruses, Spyware and other Nasties)
- SQL Create table error (ASP.NET)
- my screen doesnt startup (Troubleshooting Dead Machines)
- CD drives not working (Windows NT / 2000 / XP / 2003)
- Help with Login Box (PHP)
- cannot find server - Microsoft Internet Explorer afterdownloading Win Service pack 2 (Networking Hardware Configuration)
- How to be Crash Free (C++)
- Mobility Radeon is Unstable (Windows NT / 2000 / XP / 2003)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Draggable boxes
- Next Thread: Disabling toolbar Firefox



Linear Mode