PDA

View Full Version : JavaScript help (Spry is involved!)




LtRammstein
Dec 29, 2006, 01:34 AM
Okay, I'm hosting this Bowl Pick Challenge and I'm trying to make it so it automates the points, problem is JavaScript (and I believe Spry too) is acting up in a way where it will do a self document.write() and display 1000!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry/" >
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Other Predictions</title>
<script type="text/javascript" src="includes/xpath.js"></script>
<script type="text/javascript" src="includes/SpryData.js"></script>
<script type="text/javascript" src="includes/SpryEffects.js"></script>
<script type="text/javascript">
var dsBowlGame = new Spry.Data.XMLDataSet("bowlgames.xml", "bowlgames/game", {useCache:true});
//dsBowlGame.loadData();
function count(name,outcome) {
var x = 0;
if(name == outcome) {
x = x + 1;
} else {
x= x + 0;
}
return x;
}

function total(x) {
var t = 0
t += x;
return x;
}
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Times New Roman, Times, serif;
font-size: 14px;
color: #FFFFFF;
}
body {
background-color: #333333;
margin-left: 5px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
}
a:link {
color: #FFFF00;
}
a:visited {
color: #FFFFFF;
}

.odd {
background-color:#666666;
}

.win {
font-family: Times New Roman, Times, serif;
font-size: 14px;
color: #00FF00;

}

.lose {
font-family: Times New Roman, Times, serif;
font-size: 14px;
color: #FF0000;

}
-->
</style></head>
<body onload="javascript:Spry.Effect.AppearFade('1', {duration:3000,from:0,to:100,toggle:false});" alink="#FFFF00" vlink="#FFFFFF">
Below are the bowl picks tha people have picked. I have gotten the code written so that <span style="color:#00FF00">Wins</span> and <span style="color:#FF0000">Losses</span> are their respective colors. Enjoy seeing people's picks! Wanna see what the experts picked? Go <a href="http://www.sportsline.com/collegefootball/expertpicks" target="_blank">here</a> to find out! </p>
<div align="left" spry:detailregion="dsBowlGame" style="opacity:0.0; filter:alpha(opacity=0)" id="1">
<table width="100%" border="1" cellpadding="1" cellspacing="0" bordercolor="#000000" align="center">
<tr>
<th width="3%" onclick="dsBowlGame.sort('@id');">#</th>
<th onclick="dsBowlGame.sort('steve');">Steve's Pick</th>
<th onclick="dsBowlGame.sort('brandon');">Brandon's Pick</th>
<th onclick="dsBowlGame.sort('gabe');">Gabe's Pick</th>
<th onclick="dsBowlGame.sort('kevin');">Kevin's Pick</th>
<th onclick="dsBowlGame.sort('rem');">Rem's Pick</th>
</tr>
<tr spry:repeat="dsBowlGame" spry:odd="odd">
<td align="center">{@id}</td>
<td align="center">
<div spry:choose="spry:choose">
<div spry:when="'{steve}' == '{winner}'" class="win">{steve}</div>
<div spry:when="'{winner}' == ' '">{steve}</div>
<div spry:when="'{steve}' != '{winner}' && '{winner}' != ' '" class="lose">{steve}</div>
<div spry:default="spry:default">{steve}</div>
</div>
</td>
<td align="center">
<div spry:choose="spry:choose">
<div spry:when="'{brandon}' == '{winner}'" class="win">{brandon}</div>
<div spry:when="'{winner}' == ' '">{brandon}</div>
<div spry:when="'{brandon}' != '{winner}' && '{winner}' != ' '" class="lose">{brandon}</div>
<div spry:default="spry:default">{brandon}</div>
</div>
</td>
<td align="center">
<div spry:choose="spry:choose">
<div spry:when="'{gabe}' == '{winner}'" class="win">{gabe}</div>
<div spry:when="'{winner}' == ' '">{gabe}</div>
<div spry:when="'{gabe}' != '{winner}' && '{winner}' != ' '" class="lose">{gabe}</div>
<div spry:default="spry:default">{gabe}</div>
</div>
</td>
<td align="center">
<div spry:choose="spry:choose">
<div spry:when="'{kevin}' == '{winner}'" class="win">{kevin}</div>
<div spry:when="'{winner}' == ' '">{kevin}</div>
<div spry:when="'{kevin}' != '{winner}' && '{winner}' != ' '" class="lose">{kevin}</div>
<div spry:default="spry:default">{kevin}</div>
</div>
</td>
<td align="center">
<div spry:choose="spry:choose">
<div spry:when="'{rem}' == '{winner}'" class="win">{rem}</div>
<div spry:when="'{winner}' == ' '">{rem}</div>
<div spry:when="'{rem}' != '{winner}' && '{winner}' != ' '" class="lose">{rem}</div>
<div spry:default="spry:default">{rem}</div>
</div>
</td>
</tr>
<tr>
<td>
<div>Total:</div>
</td>
<td id="steve" align="center">
<div style="visibility:hidden">
<script language="javascript">
document.getElementById("steve").innerHTML = total(count('{steve}','{winner}'));
</script>
</div>
</td>
<!--<td>
<div>
<script language="javascript">
document.write(count('{brandon}','{winner}'));
</script>
</div>
</td>
<td>
<div>
<script language="javascript">
document.write(count('{gabe}','{winner}'));
</script>
</div>
</td>
<td>
<div>
<script language="javascript">
document.write(count('{kevin}','{winner}'));
</script>
</div>
</td>
<td>
<div>
<script language="javascript">
document.write(count('{rem}','{winner}'));
</script>
</div>
</td>-->
</tr>
</table>
</div>
</body>
</html>


What will happen is that the page will display but it will continually load so it's impossible to do anything! Any suggestions or helps on what I'm doing wrong?

Steve



LtRammstein
Dec 29, 2006, 03:11 AM
I have reached a solution... Not the best in the world, but it works.

http://www.sigmanuepsilondelta.com/predict.html

This will do (if you view the source). Any suggestions on making it better, I'll gladly take into consideration!