JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 2nd, 2007, 12:20 PM
guyaton guyaton is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 1 guyaton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 42 sec
Reputation Power: 0
ImageBtn has no properties

Let me say first, that I am pretty sure what the problem is however I do not know how to solve it.

The problem:
The problem is that I am getting this error "ImageBtn has no properties" during my Javascript execution because the < DIV > it is in is initially HIDDEN.

What I am doing:
I am using AJAX to request information from a database on the server, and using what is returned from the server to Make Image buttons appear at the bottom of the screen. I have all of the Image buttons contained within a < DIV > and am making it visible (the div is initially set invisible) when I set the attributes for the Image buttons.


How do I get this working? Here is some of the code:

Code:
//This is the callback from AJAX
function ParseBuildingInfo()
{
    //readyState of 4 or 'complete' represents that data has been returned
    if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == 'complete')
    {
		var strUpgrade = objXmlHttp.responseText.split( '\n' );
		
		for( i=0; i<strUpgrade.length; i+=6 )
		{
			var ID_arr = i / 8;
			i++;
	
			showdiv( "Building_Upgrades" );	
			
			// The array IDs contains all the IDs after ASP.NET is done making them unique.
			var ImageBtn = document.getElementById( IDs[ID_arr] );
			
			ImageBtn.title = strUpgrade[i+1] + '\n' + "W:" + strUpgrade[i+2] +
				"  I:" + strUpgrade[i+3] + "  S:" + strUpgrade[i+4] + "  G:" + strUpgrade[i+5] + " Time:" + strUpgrade[i+6]; 
			ImageBtn.src = strUpgrade[i+1];
		}
		
    }
}

//This is how I am hiding my . Show div is the same except it uses "block"
function hidediv(id) 
{
	//safe function to hide an element with a specified id
	if (document.getElementById) 
	{ 
		// DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else 
	{
		if (document.layers)
		{ 
			// Netscape 4
			document.id.display = 'none';
		}
		else
		{ 
			// IE 4
			document.all.id.style.display = 'none';
		}
	}
}


As a side note, how do I prevent javascript from converting the '/' in the url to %5C. Ex. In my script above, when setting the ImageBtn.src, javascript inserts "%5CImages%5CbtnBuilding1.PNG" but on the DB it is "\Images\btnBuilding1.PNG"


I hope my intentions are clear enough.

Thank you for your help!

Reply With Quote
  #2  
Old August 2nd, 2007, 10:31 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Click here for more information
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 549 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 3 m
Reputation Power: 4
no properties

Hi guyaton, welcome to the forums,
Maybe if you used the "visibility" property instead of the "display" property it would work OK. A difference would be that the browser will allocate the space for the hidden div when it renders the page so the "empty space" may not look so good until the images fill in.
As for the url escaped string, maybe you can simply have the code replace any %5c with a / ??

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > ImageBtn has no properties


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT