Tom Powers
asked on
CAN'T LOAD OTHER IMAGES
a GUY HELPED ME out with this code the only thing is is that if a different xml file is used the Ballpark field doesnot load.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SportsNetwork</titl e>
<style>
#teamH { float:left}
#teamA { float:right}
#content { width:500px}
#img { }
.caption {text-align:center; margin:auto; font-weight: bold}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></s cript>
<script>
stadiums = {
"wrigley field":"wrigley.gif",
"comerica park":"comerica.gif" ,
"yankee stadium":"yankee.jpg" ,
"shea stadium":"shea.jpg" ,
"angel stadium of anaheim":"angel.jpg" ,
"rangers ballpark in arlington":"angel.jpg" ,
"at&t park":"attpark.jpg" ,
"citizens bank park":"citizenballpark.jpg " ,
"coors field":"coors.jpg" ,
"busch stadium":"busch.jpg" ,
"oriole park at camden yards":"camden_baltimore.j pg"
,"dodger stadium":"dodgers.jpg" ,
"chase field":"chasefield.jpg" ,
"tropicana field":"tropicana.jpg" ,
"great american ball park":"greatamerican.jpg" ,
"kauffman stadium":"kauffmanstadium. jpg" ,
"mcafee coliseum":"mcafeecoliseum. jpg" ,
"hubert h. humphrey metrodome":"metrodome.jpg" ,
"metrodome":"metrodome.jpg " ,
"miller park":"millerpark.jpg" ,
"minute maid park":"minutemaid.jpg" ,
"nationals park":"nationalspark.jpg" ,
"petco park":"petcopark.jpg" ,
"petco park":"petcopark.jpg" ,
"pnc park":"pncpark.jpg" ,
"progressive field":"progressive.jpg" ,
"rogers centre":"rogerscentre.jpg" ,
"safeco field":"safecofield.jpg" ,
"turner field":"turnerfield.jpg" ,
"dolphin stadium":"dolphinstadium.j pg" ,
"fenway park":"fenwaypark.jpg" ,
"u.s. cellular field":"uscellularfield.jp g" ,
"oakland-alameda county coliseum": "mcafeecoliseum.jpg"
} // no comma on the last
var homeTurf = {
"philadelphia":"Citizens bank park",
"milwaukee":"Miller park"
}
// or simply have
/*
var homeTurf = {
"philadelphia":"citizensba llpark.jpg ",
"milwaukee":"millerpark.jp g"
}
*/
$(document).ready(function (){
$.ajax({
type: "GET",
url: "33661.XML",
dataType: "xml",
success: function(data){
var Teams = $(data).find("Team");
$.each(Teams,function(i,Te am) {
team=$(Team);
var id = team.attr("ID").toLowerCas e();
var teamLogo = $("<img/>").attr("src","http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/" + id + ".png");
var homeOrAway = team.attr("vh");
$("#team"+homeOrAway).appe nd(teamLog o);
if (homeOrAway=="H") {
var stadium_location = stadiums[homeTurf[name].to LowerCase( )]; // or have
var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
url = (stadium_location) ?url + stadium_location:"default. gif";
$("#imgDiv").append('<img src="'+url+'"/>').append(' <br/><div class="caption">'+homeTurf [name]+'</ div>');
}
});
}
});
});
</script>
</head>
<body>
<div id="content">
<span id="teamH"></span>
<span id="teamA"></span><br/>
<div id="scoreboard"></div><br/ >
<div id="imgDiv"></div>
</div>
</body>
</html>
Can anyone know how to use entire list to load correct staduim I attached a different XML so you can test it.Everytime I edit any of these files I end up getting blank pages. mplungjan has done some amazing work for me I can't afford to pay him if I had money or controled the cash at my gig I would pay him however I might get him some lottery tickets
33661.XML
33662.xml
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SportsNetwork</titl
<style>
#teamH { float:left}
#teamA { float:right}
#content { width:500px}
#img { }
.caption {text-align:center; margin:auto; font-weight: bold}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></s
<script>
stadiums = {
"wrigley field":"wrigley.gif",
"comerica park":"comerica.gif" ,
"yankee stadium":"yankee.jpg" ,
"shea stadium":"shea.jpg" ,
"angel stadium of anaheim":"angel.jpg" ,
"rangers ballpark in arlington":"angel.jpg" ,
"at&t park":"attpark.jpg" ,
"citizens bank park":"citizenballpark.jpg
"coors field":"coors.jpg" ,
"busch stadium":"busch.jpg" ,
"oriole park at camden yards":"camden_baltimore.j
,"dodger stadium":"dodgers.jpg" ,
"chase field":"chasefield.jpg" ,
"tropicana field":"tropicana.jpg" ,
"great american ball park":"greatamerican.jpg" ,
"kauffman stadium":"kauffmanstadium.
"mcafee coliseum":"mcafeecoliseum.
"hubert h. humphrey metrodome":"metrodome.jpg"
"metrodome":"metrodome.jpg
"miller park":"millerpark.jpg" ,
"minute maid park":"minutemaid.jpg" ,
"nationals park":"nationalspark.jpg" ,
"petco park":"petcopark.jpg" ,
"petco park":"petcopark.jpg" ,
"pnc park":"pncpark.jpg" ,
"progressive field":"progressive.jpg" ,
"rogers centre":"rogerscentre.jpg"
"safeco field":"safecofield.jpg" ,
"turner field":"turnerfield.jpg" ,
"dolphin stadium":"dolphinstadium.j
"fenway park":"fenwaypark.jpg" ,
"u.s. cellular field":"uscellularfield.jp
"oakland-alameda county coliseum": "mcafeecoliseum.jpg"
} // no comma on the last
var homeTurf = {
"philadelphia":"Citizens bank park",
"milwaukee":"Miller park"
}
// or simply have
/*
var homeTurf = {
"philadelphia":"citizensba
"milwaukee":"millerpark.jp
}
*/
$(document).ready(function
$.ajax({
type: "GET",
url: "33661.XML",
dataType: "xml",
success: function(data){
var Teams = $(data).find("Team");
$.each(Teams,function(i,Te
team=$(Team);
var id = team.attr("ID").toLowerCas
var teamLogo = $("<img/>").attr("src","http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/" + id + ".png");
var homeOrAway = team.attr("vh");
$("#team"+homeOrAway).appe
if (homeOrAway=="H") {
var stadium_location = stadiums[homeTurf[name].to
var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
url = (stadium_location) ?url + stadium_location:"default.
$("#imgDiv").append('<img src="'+url+'"/>').append('
}
});
}
});
});
</script>
</head>
<body>
<div id="content">
<span id="teamH"></span>
<span id="teamA"></span><br/>
<div id="scoreboard"></div><br/
<div id="imgDiv"></div>
</div>
</body>
</html>
Can anyone know how to use entire list to load correct staduim I attached a different XML so you can test it.Everytime I edit any of these files I end up getting blank pages. mplungjan has done some amazing work for me I can't afford to pay him if I had money or controled the cash at my gig I would pay him however I might get him some lottery tickets
33661.XML
33662.xml
ASKER
The stadium is suppose to load under two team logos that's all the code for stadiums
stadiums = {
"wrigley field":"wrigley.gif",
"comerica park":"comerica.gif" ,
"yankee stadium":"yankee.jpg" ,
"shea stadium":"shea.jpg" ,
"angel stadium of anaheim":"angel.jpg" ,
"rangers ballpark in arlington":"angel.jpg" ,
"at&t park":"attpark.jpg" ,
"citizens bank park":"citizenballpark.jpg " ,
"coors field":"coors.jpg" ,
"busch stadium":"busch.jpg" ,
"oriole park at camden yards":"camden_baltimore.j pg"
,"dodger stadium":"dodgers.jpg" ,
"chase field":"chasefield.jpg" ,
"tropicana field":"tropicana.jpg" ,
"great american ball park":"greatamerican.jpg" ,
"kauffman stadium":"kauffmanstadium. jpg" ,
"mcafee coliseum":"mcafeecoliseum. jpg" ,
"hubert h. humphrey metrodome":"metrodome.jpg" ,
"metrodome":"metrodome.jpg " ,
"miller park":"millerpark.jpg" ,
"minute maid park":"minutemaid.jpg" ,
"nationals park":"nationalspark.jpg" ,
"petco park":"petcopark.jpg" ,
"petco park":"petcopark.jpg" ,
"pnc park":"pncpark.jpg" ,
"progressive field":"progressive.jpg" ,
"rogers centre":"rogerscentre.jpg" ,
"safeco field":"safecofield.jpg" ,
"turner field":"turnerfield.jpg" ,
"dolphin stadium":"dolphinstadium.j pg" ,
"fenway park":"fenwaypark.jpg" ,
"u.s. cellular field":"uscellularfield.jp g" ,
"oakland-alameda county coliseum": "mcafeecoliseum.jpg"
} // no comma on the last
This Part is suppose to load stadium based on Location Name in xml file here is the call for the stadiums
var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
url = (stadium_location) ?url + stadium_location:"default. gif";
$("#imgDiv").append('<img src="'+url+'"/>').append(' <br/><div class="caption">'+homeTurf [name]+'</ div>');
stadiums = {
"wrigley field":"wrigley.gif",
"comerica park":"comerica.gif" ,
"yankee stadium":"yankee.jpg" ,
"shea stadium":"shea.jpg" ,
"angel stadium of anaheim":"angel.jpg" ,
"rangers ballpark in arlington":"angel.jpg" ,
"at&t park":"attpark.jpg" ,
"citizens bank park":"citizenballpark.jpg
"coors field":"coors.jpg" ,
"busch stadium":"busch.jpg" ,
"oriole park at camden yards":"camden_baltimore.j
,"dodger stadium":"dodgers.jpg" ,
"chase field":"chasefield.jpg" ,
"tropicana field":"tropicana.jpg" ,
"great american ball park":"greatamerican.jpg" ,
"kauffman stadium":"kauffmanstadium.
"mcafee coliseum":"mcafeecoliseum.
"hubert h. humphrey metrodome":"metrodome.jpg"
"metrodome":"metrodome.jpg
"miller park":"millerpark.jpg" ,
"minute maid park":"minutemaid.jpg" ,
"nationals park":"nationalspark.jpg" ,
"petco park":"petcopark.jpg" ,
"petco park":"petcopark.jpg" ,
"pnc park":"pncpark.jpg" ,
"progressive field":"progressive.jpg" ,
"rogers centre":"rogerscentre.jpg"
"safeco field":"safecofield.jpg" ,
"turner field":"turnerfield.jpg" ,
"dolphin stadium":"dolphinstadium.j
"fenway park":"fenwaypark.jpg" ,
"u.s. cellular field":"uscellularfield.jp
"oakland-alameda county coliseum": "mcafeecoliseum.jpg"
} // no comma on the last
This Part is suppose to load stadium based on Location Name in xml file here is the call for the stadiums
var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
url = (stadium_location) ?url + stadium_location:"default.
$("#imgDiv").append('<img src="'+url+'"/>').append('
ASKER
In xml file location has the name of the stadium to be loaded and the stadiums function above is supposed to load the staduim image based on Location name match. Hope that explains it better.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I understand now thanks to you. Your great.
Open in new window
the page shows images for Angels and Giantswith
Open in new window
the page shows images for Brewers and Phillies.What is the issue?