The flat file looks kinda like this:
FileName:GraphicName:Keywords
Example; AceSpades:Ace of Spades:Ace, Spades, Black, High card.......
In this instance, I am only using FileName. If I haven't completely confused everyone, any suggestions are appreciated. :-) If I have confused everyone, drop me a note and I will try to be more clear......
An example of the output is:
The first example is what should be displayed, the second is what I sometimes get.... The script is below.<DIV CLASS="Location1_1"> <IMG SRC="../tiles/thumbs/backside.jpg" id="Dagaz" onClick="trackClick +s(this)"> </DIV> <DIV CLASS="Location1_2"> <IMG SRC="../tiles/thumbs/backside.jpg" id="" onClick="trackClicks(thi +s)"> </DIV>
#!e:\perl\perl.exe use CGI; use warnings; use Tie::File; use List::Util qw(shuffle); $query = CGI::new(); $Spread = $query->param("Spread"); $i=0; @place2 = qw(0 1_1 1_2 1_3 1_4 1_5 1_6 2_1 2_2 2_3 2_4 2_5 2_6 3_1 3_2 + 3_3 3_4 3_5 3_6 4_1 4_2 4_3 4_4 4_5 4_6); open(FILE,"< tiles.txt") or die "error opening tiles.txt $!"; tie @text, 'Tie::File', 'tiles.txt' or die $!; @text = shuffle(@text); while (<FILE>) { ($File[$i++], $Name[$i++], $Keywords[$i++]) = split(/:/; chomp ($Keywords[$i]); } close(FILE); print "content-type:text/html\n\n"; print "<HTML>\n<HEAD>\n"; print "<style type=\"text/css\">\n<!--\n"; print "\@import url(\"../styles.css\");\n//-->\n"; print "</style>\n\n"; print "<script type=\"text/javascript\">\n"; print "var max = $Count;\n"; print "function trackClicks(img) {\n"; print "self.c = self.c?c:0;\n"; print "self.cache = self.cache?cache:[];\n"; print "var found = false;\n"; print "for (var x = 0; x < cache.length; x++) {\n"; print "if (cache[x] == img.id) found = true;\n"; print "}\n"; print "if (!found) {\n"; print "cache.push(img.id);\n"; print "c++;\n"; print "}\n"; print "if (c >= max) {\n"; print "alert(cache)\n"; print "document.Selections.Cache.value=cache\n"; print "document.forms[0].submit();\n"; print "}\n"; print "}\n"; print "</script>\n"; print "</HEAD>\n"; print "<body>\n"; print "<DIV CLASS=\"MainWindow\">\n"; print "Test Layout<P>\n"; print "<DIV CLASS=\"MainContent\">\n"; print "<FORM NAME=\"Selections\" action=\"ShowLayout.pl\" method=\"POS +T\">\n"; for ($z=1; $z<=24; $z++) { print "<DIV CLASS=\"Location$place2[$z]\">\n"; print "<IMG SRC=\"../tiles/thumbs/backside.jpg\" id=\"$File[$z]\" onCl +ick=\"trackClicks(this)\">\n"; print "</DIV>\n"; } print "<Input type=\"hidden\" Name=\"Stones\" Value=\"$Stones\">\n"; print "<Input type=\"hidden\" Name=\"Cache\" Value=\"cache\">\n"; print "</FORM>\n";
In reply to Code not showing properly by JimJx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |