User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Feb 2008
Posts: 2
Reputation: CathInfo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
CathInfo CathInfo is offline Offline
Newbie Poster

Help Error message makes no sense! Help!

  #1  
Feb 29th, 2008
Please, anyone, tell me how can this be:

	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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,433
Reputation: MidiMagic is on a distinguished road 
Rep Power: 6
Solved Threads: 99
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Posting Maven

Re: Error message makes no sense! Help!

  #2  
Mar 1st, 2008
The first statement is different.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC