Solved

Load two end zone Images on a football field image

Posted on 2013-06-28
2
320 Views
Last Modified: 2013-06-28
I have a football field and I need to load both end zones with images I created a transparent image called blank.gif I constructed javascript/jquery code based on previous code it's not loading but Endzones for this xml file are here is home this is whqat I need to load into a Blank.gif it's like a placeholder http://images.sportsnetwork.com/nfl/atthegridiron/end_zone2/081_home.jpg

I need both endzones here is code let me know what is missing
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>The sports Network</title>
<style type="text/css">
.formatcell {
	text-align: center;
	vertical-align: top;
}
.textbox {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-size: x-small;
	color: #000;
	background-color: #FC6;
}
#awayendzone {
	position: absolute;
	width: 60px;
	height: 252px;
	z-index: 1;
	left: 48px;
	top: 23px;
}
#apDiv1 {
	position: absolute;
	width: 60px;
	height: 252px;
	z-index: 2;
	left: 708px;
	top: 23px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
  var xmlPath = '.'; // '/xml/nfl/scores/real';
  var xmlGameID = 'AB-3171'; // game id only, _counter.xml will be added in the ajax call
  var counterXml = 0;

  var teamNames = {
    "079": "GIANTS",
    "068": "LIONS",
    "084": "49ERS",
    "063": "BEARS",
    "083": "CHARGERS",
    "085": "SEAHAWKS",
    "088": "REDSKINS",
    "061": "FALCONS",
    "062": "BILLS",
    "064": "BENGALS",
    "065": "RAVENS",
    "066": "COWBOYS",
    "067": "BRONCOS",
    "069": "PACKERS",
    "070": "TITANS",
    "071": "COLTS",
    "072": "CHIEFS",
    "073": "RAIDERS",
    "074": "RAMS",
    "075": "DOLPHINS",
    "076": "VIKINGS",
    "077": "PATRIOTS",
    "078": "SAINTS",
    "080": "JETS",
    "081": "EAGLES",
    "082": "STEELERS",
    "086": "CARDINALS",
    "087": "BUCS",
    "089": "PANTHERS",
    "090": "JAGUARS",
    "120": "BROWNS",
    "151": "TEXANS",
    "685": "A-F-C",
    "686": "N-F-C"
  };
 $(document).ready(function(){
    $.ajax({
      type: "GET",
      url:  xmlPath+"/"+xmlGameID+"_0.xml",
      dataType: "xml",
      success: function(data){
        var d = $(data);
        d.find('Team').each(function(i,Team){
          var team=$(Team);
          var id = team.attr("ID").toLowerCase();
          var teamname = team.attr("name");
          var homeOrAway = team.attr("vh");
          var selector1 = (homeOrAway=="A") ? '#Visitor' : '#Hometeam' ;
          var selector2 = (homeOrAway=="A") ? '#VTeamname' : '#HTeamName' ;
          
		  //$(selector1).html(teamname);
         // $(selector2).html(teamNames[id]);
		   
          
		  
        });
      }
    });
  });

  
  
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
		
		
       function loadData() {
  $.ajax({
    type: "GET",
    url:  xmlPath+"/"+xmlGameID+'_'+counterXml+".xml",
    dataType: "xml",
    success: function(data) {
      var d = $(data);
      var Play = d.find('Play');
      d.find('Team').each(function(i,Team){
        if ($(Team).attr('vh') == "A") {
          $('#imgawayEZ').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone2/'+$(Team).attr('ID')+"_away.jpg'");
         
		  
		 // $('#VRd').show()
		  // $('#VRtg').show()
         
        }
        if ($(Team).attr('vh') == "H") {
          $('#imghomeEZ').attr('src', 'http://images.sportsnetwork.com/nfl/atthegridiron/end_zone2/'+$(Team).attr('ID')+"_home.jpg'");
          
		  // $('#VRd').hide();
		  // $('#VRtg').hide();
		   
          
        }
      }); // each
        // changed all below to just use the variables that contain the text directly, as the arrays do not exist and don't seem necessary in this situation
     
      ++counterXml;
    }  
  }); //ajax

  }

</script>
</head>

<body>
<table width="800" border="0">
  <tr>
    <td><div>
      <div id="awayendzone"><img src="Blank.gif" name="imgawayEZ" width="60" height="252" id="imgawayEZ"></div>
    <img src="Field.fw.png" width="797" height="315">
    <div id="apDiv1"><img src="Blank.gif" name="imghomeEZ" width="60" height="252" id="imghomeEZ"></div>
    </div></td>
  </tr>
  <tr>
    <td bgcolor="#000000" class="formatcell">
    <textarea name="txtNarrative" cols="100" rows="3" class="textbox" id="txtNarrative"></textarea></td>
  </tr>
</table>
</body>
<script>
var myVar=setInterval(function(){myTimer()},1000);

function myTimer()
{

loadData();

}
</script>
</html>

Open in new window

You really only need one xml file for this to run but I'll include
If you now how to code Narrative Text in xml to show in textbox that would be greatly appreciated Just not sure how to load text into Textbox that increments I'll include 10 xml football game files so you get a idea or something to play with.
AB-3171-0.xml
AB-3171-1.xml
AB-3171-2.xml
AB-3171-3.xml
AB-3171-4.xml
AB-3171-5.xml
AB-3171-6.xml
AB-3171-7.xml
AB-3171-8.xml
AB-3171-9.xml
AB-3171-10.xml
GridIron.html
Field.fw.png
0
Comment
Question by:powerztom
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39285633
On lines 116 and 124 there is an extra single quote near the end of the line:
+"_away.jpg'");

Open in new window

needs to be:
+"_away.jpg");

Open in new window

and same thing:
+"_home.jpg'");

Open in new window

needs to be:
+"_home.jpg");

Open in new window

That seems to be all, the rest works like a charm.
0
 

Author Closing Comment

by:powerztom
ID: 39285640
A simple fix but it was something I didn't see Awesome Rob
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now