Hi there,
I'm having a problem trying to update my site. I run a small fantasy league soccer game with my friends and am trying to make the input of player updates quicker. Currently this works by each player having their own points update page which takes quite a while to go through each one individually! So, i'm trying to get this all on one page which looks like this:
http://www.freefantasyleague.co.uk/Project/UpdatePoints1.asp?code=1I previously had javascript code that looked like this:
<script language="JavaScript1.2">
function total() {
var d = document.points;
var ttl = 0;
ttl += eval( d.Goals.options[d.Goals.se
lectedInde
x].value * 3 );
ttl += eval( d.Assists.options[d.Assist
s.selected
Index].val
ue * 2 );
if ( d.CleanSheets.selectedInde
x > 0 ) {
ttl += 3;
}
if ( d.GoalsAgainst.selectedInd
ex > 1 ) {
ttl -= eval( d.GoalsAgainst.options[d.G
oalsAgains
t.selected
Index].val
ue ) - 1;
}
d.Total.value = ttl;
}
</script>
This calculate the points based on the selections made in the drop downs (played, goals, assists etc etc...). Now i've got all of these on the same page i'm not sure how to make this box calculate it for each player...throwing up all sorts of JavaScript errors! :)
Is there anyone who knows the amendment i'd need to make to getthis working again?
The code for the entire page (including the asp) is:
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="DatabaseConnect.asp"
-->
<!--#include virtual="/adovbs.inc"-->
<%
'If Session("isadmin") = False then
'response.redirect("login.
asp")
'end if
Dim strSQLnews, objrsnews, strCode
set objrsnews = Server.CreateObject("ADODB
.recordset
")
strSQLnews = "Select * From News_Items where News_Date Between date() and date() -2 order by News_date desc"
objrsnews.Open strSQLnews, objconn
strCode = Cint(Request.QueryString("
code"))
Dim strSQL, objrs
set objrs = Server.CreateObject("ADODB
.recordset
")
strSQL = "Select * From players where Team = Cint('" & strCode & "') and Position = 'GK'"
objrs.Open strSQL, objconn
Dim strSQLFB, objrsFB
set objrsFB = Server.CreateObject("ADODB
.recordset
")
strSQLFB = "Select * From players where Team = Cint('" & strCode & "') and Position = 'FB'"
objrsFB.Open strSQLFB, objconn
Dim strSQLCB, objrsCB
set objrsCB = Server.CreateObject("ADODB
.recordset
")
strSQLCB = "Select * From players where Team = Cint('" & strCode & "') and Position = 'CB'"
objrsCB.Open strSQLCB, objconn
Dim strSQLMF, objrsMF
set objrsMF = Server.CreateObject("ADODB
.recordset
")
strSQLMF = "Select * From players where Team = Cint('" & strCode & "') and Position = 'MF'"
objrsMF.Open strSQLMF, objconn
Dim strSQLCF, objrsCF
set objrsCF = Server.CreateObject("ADODB
.recordset
")
strSQLCF = "Select * From players where Team = Cint('" & strCode & "') and Position = 'CF'"
objrsCF.Open strSQLCF, objconn
Dim strSQL2, objrs2
set objrs2 = Server.CreateObject("ADODB
.recordset
")
strSQL2 = "Select * From clubs where Team = Cint('" & strCode & "')"
objrs2.Open strSQL2, objconn
Dim objrs3, strSQL3
set objrs3 = Server.CreateObject("ADODB
.recordset
")
strSQL3 = "Select * From Results where Game_Date Between Date() and Date() - 5"
objrs3.Open strSQL3, objconn
%>
<html>
<head>
<script language="JavaScript1.2">
function total() {
var d = document.points;
var ttl = 0;
ttl += eval( d.Goals.options[d.Goals.se
lectedInde
x].value * 3 );
ttl += eval( d.Assists.options[d.Assist
s.selected
Index].val
ue * 2 );
if ( d.CleanSheets.selectedInde
x > 0 ) {
ttl += 3;
}
if ( d.GoalsAgainst.selectedInd
ex > 1 ) {
ttl -= eval( d.GoalsAgainst.options[d.G
oalsAgains
t.selected
Index].val
ue ) - 1;
}
d.Total.value = ttl;
}
</script>
<script language="JavaScript1.2">
var ns6=document.getElementByI
d&&!docume
nt.all
var ie=document.all
function changeto(e,highlightcolor)
{
source=ie? event.srcElement : e.target
if (source.tagName=="TR"||sou
rce.tagNam
e=="TABLE"
)
return
while(source.tagName!="TD"
&&source.t
agName!="H
TML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundCo
lor!=highl
ightcolor&
&source.id
!="ignore"
)
source.style.backgroundCol
or=highlig
htcolor
}
function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}
function changeback(e,originalcolor
){
if
(ie&&(event.fromElement.co
ntains(eve
nt.toEleme
nt)||sourc
e.contains
(event.toE
lement)||s
ource.id==
"ignore")|
|source.ta
gName=="TR
"||source.
tagName=="
TABLE")
return
else if (ns6&&(contains_ns6(source
, e.relatedTarget)||source.i
d=="ignore
"))
return
if (ie&&event.toElement!=sour
ce||ns6&&e
.relatedTa
rget!=sour
ce)
source.style.backgroundCol
or=origina
lcolor
}
</script>
</head>
<link href="MainStyle.css" type="text/css" rel="stylesheet">
<title>Fantasy League</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
Document">
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor ="98ABBA">
<table border="0" width="838" height="521" >
<tr>
<td width="832" colspan="3" height="53">
<p align="left"><img src = "Images/LogoMain/logomain.
gif" width="397" height="69"><img src = "Images/LogoMain/logomain1
.jpg"></p>
</td>
</tr>
<tr>
<td width="134" height="438" valign = "top" bgcolor="#98ABBA" rowspan="4">
<div align="center" style="width: 132; height: 124">
<center>
<div align="justify">
<table border="1" bordercolor="#98ABBA" width="99%" onMouseover="changeto(even
t, '#9AABBC')" onMouseout="changeback(eve
nt, '#7C8E98')" bgcolor="#7C8E98" cellpadding="0" height="134" cellspacing="1">
<tr>
<a href="login.asp"><td width="100%" align="center" height="14">Login</td></a>
</tr>
<%If Session("loggedin") = true Then%>
<tr>
<a style="text-decoration: none" href="user_main.asp"><td width="100%" align="center" height="17">Your Team</td></a>
</tr>
<%End If%>
<tr>
<a href="register2_original.a
sp"><td width="100%" align="center" height="17">Register</td><
/a>
</tr>
<tr>
<a href="players.asp"><td width="100%" align="center" height="17">Players</td></
a>
</tr>
<tr>
<a href="forum.asp"><td width="100%" align="center" height="17">Forum</td></a>
</tr>
<tr>
<a href="Help.asp"><td width="100%" align="center" height="17">Help</td></a>
</tr>
<tr>
<a href="default.asp"><td width="100%" align="center" height="17">Home</td></a>
</tr>
<%If Session("isadmin") = true Then%>
<tr>
<a style="text-decoration: none" href="admin.asp"><td width="100%" align="center" height="17">Administrator Options</td></a>
</tr>
<%End If%>
</center>
<tr>
<td width="100%" align="left" height="1" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</div>
</div>
</td>
<td width="705" height="400" valign="top">
<img border="0" src="Images/Headers/TeamIn
fo.jpg"><p
>This page allows you to
update the weekly points for <%=objrs2("Club_Name")%>. Simply select the player you<br>wish to update then enter their weekly stats.</p>
<p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="71%" id="AutoNumber2">
<tr>
<td width="10%" valign="top" align="left"><%=objrs2("Cl
ub_Emblem"
)%><p></td
>
<td width="90%" valiugn="bottom" align="Left"><h2> <%=
objrs2("Cl
ub_Name")%
></h2></td
>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="105%" id="AutoNumber1" height="1">
<tr>
<td width="19%" height="12" bgcolor="#7C8E98"><font color="#FFFFFF">Goalkeeper
s:</font><
/td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="9%" height="12" bgcolor="#7C8E98"> </
td>
</tr>
<%Do until objrs.EOF%>
<tr>
<td width="19%" height="1"><a href="PointsUpdate.asp?cod
e=<%=objrs
("Code")%>
&team=<%=o
bjrs("Team
")%>"><%=o
bjrs("Play
er_Name")%
></a></td>
<td width="15%" height="1"><Select Name="Played<%=objrs("Code
")%>" style=width:100px onchange='total(3);'><opti
on value="0" selected>
--Played?--</option><optio
n Value="1">Yes</option></se
lect></td>
<td width="14%" height="1"><Select Name="Goals" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="15%" height="1"><Select Name="Assists" style = width:100px onchange='total();'><optio
n value="0" selected>
--Assists--</option><optio
n Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="14%" height="1"><Select Name="CleanSheets" style = width:100px onchange='total(3);'><opti
on value="0" selected>
--Clean Sh?--</option><option Value="1">Yes</option></se
lect></td>
<td width="15%" height="1"><Select Name="GoalsAgainst" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals Ag--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="9%" height="1"><input type="Text" Name="Total" size="4" Value="0" readonly></td>
</tr>
<%
objrs.Movenext
loop
%>
<tr>
<td width="19%" height="12" bgcolor="#7C8E98"><font color="#FFFFFF">Fullbacks:
</font></t
d>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="9%" height="12" bgcolor="#7C8E98"> </
td>
</tr>
<%Do until objrsFB.EOF%>
<tr>
<td width="19%" height="1"><a href="PointsUpdate.asp?cod
e=<%=objrs
FB("Code")
%>&team=<%
=objrsFB("
Team")%>">
<%=objrsFB
("Player_N
ame")%></a
></td>
<td width="15%" height="1">
<Select Name="Played0" style=width:100px onchange='total(3);'><opti
on value="0" selected>
--Played?--</option><optio
n Value="1">Yes</option></se
lect></td>
<td width="14%" height="1">
<Select Name="Goals0" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="15%" height="1">
<Select Name="Assists0" style = width:100px onchange='total();'><optio
n value="0" selected>
--Assists--</option><optio
n Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="14%" height="1">
<Select Name="CleanSheets0" style = width:100px onchange='total(3);'><opti
on value="0" selected>
--Clean Sh?--</option><option Value="1">Yes</option></se
lect></td>
<td width="15%" height="1">
<Select Name="GoalsAgainst0" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals Ag--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="9%" height="1">
<input type="Text" Name="Total0" size="4" Value="0" readonly></td>
</tr>
<%
objrsFB.Movenext
loop
%>
<tr>
<td width="19%" height="12" bgcolor="#7C8E98"><font color="#FFFFFF">Centerback
s:</font><
/td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="9%" height="12" bgcolor="#7C8E98"> </
td>
</tr>
<%Do Until objrsCB.EOF%>
<tr>
<td width="19%" height="1"><a href="PointsUpdate.asp?cod
e=<%=objrs
CB("Code")
%>&team=<%
=objrsCB("
Team")%>">
<%=objrsCB
("Player_N
ame")%></a
></td>
<td width="15%" height="1">
<Select Name="Played1" style=width:100px onchange='total(3);'><opti
on value="0" selected>
--Played?--</option><optio
n Value="1">Yes</option></se
lect></td>
<td width="14%" height="1">
<Select Name="Goals1" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="15%" height="1">
<Select Name="Assists1" style = width:100px onchange='total();'><optio
n value="0" selected>
--Assists--</option><optio
n Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="14%" height="1">
<Select Name="CleanSheets1" style = width:100px onchange='total(3);'><opti
on value="0" selected>
--Clean Sh?--</option><option Value="1">Yes</option></se
lect></td>
<td width="15%" height="1">
<Select Name="GoalsAgainst1" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals Ag--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="9%" height="1">
<input type="Text" Name="Total1" size="4" Value="0" readonly></td>
</tr>
<%
objrsCB.Movenext
loop
%>
<tr>
<td width="19%" height="12" bgcolor="#7C8E98"><font color="#FFFFFF">Midfielder
s:</font><
/td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="9%" height="12" bgcolor="#7C8E98"> </
td>
</tr>
<%Do until objrsMF.EOF%>
<tr>
<td width="19%" height="1"><a href="PointsUpdate.asp?cod
e=<%=objrs
MF("Code")
%>&team=<%
=objrsMF("
Team")%>">
<%=objrsMF
("Player_N
ame")%></a
></td>
<td width="15%" height="1"><Select Name="Played2" style=width:100px onchange='total(3);'><opti
on value="0" selected>
--Played?--</option><optio
n Value="1">Yes</option></se
lect></td>
<td width="14%" height="1">
<Select Name="Goals2" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="15%" height="1">
<Select Name="Assists2" style = width:100px onchange='total();'><optio
n value="0" selected>
--Assists--</option><optio
n Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="14%" height="1">
<Select Name="CleanSheets2" style = width:100px onchange='total(3);'><opti
on value="0" selected>
--Clean Sh?--</option><option Value="1">Yes</option></se
lect></td>
<td width="15%" height="1">
<Select Name="GoalsAgainst2" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals Ag--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="9%" height="1">
<input type="Text" Name="Total2" size="4" Value="0" readonly></td>
</tr>
<%
objrsMF.Movenext
loop
%>
<tr>
<td width="19%" height="12" bgcolor="#7C8E98"><font color="#FFFFFF">Strikers:<
/font></td
>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="14%" height="12" bgcolor="#7C8E98"> </
td>
<td width="15%" height="12" bgcolor="#7C8E98"> </
td>
<td width="9%" height="12" bgcolor="#7C8E98"> </
td>
</tr>
<%Do until objrsCF.EOF%>
<tr>
<td width="19%" height="1"><a href="PointsUpdate.asp?cod
e=<%=objrs
CF("Code")
%>&team=<%
=objrsCF("
Team")%>">
<%=objrsCF
("Player_N
ame")%></a
></td>
<td width="15%" height="1">
<Select Name="Played3" style=width:100px onchange='total(3);'><opti
on value="0" selected>
--Played?--</option><optio
n Value="1">Yes</option></se
lect></td>
<td width="14%" height="1">
<Select Name="Goals3" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="15%" height="1">
<Select Name="Assists3" style = width:100px onchange='total();'><optio
n value="0" selected>
--Assists--</option><optio
n Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="14%" height="1">
<Select Name="CleanSheets3" style = width:100px onchange='total(3);'><opti
on value="0" selected>
--Clean Sh?--</option><option Value="1">Yes</option></se
lect></td>
<td width="15%" height="1">
<Select Name="GoalsAgainst3" style = width:100px onchange='total();'><optio
n value="0" selected>
--Goals Ag--</option><option Value="1">One</option><opt
ion value="2">Two</option><opt
ion value="3">
Three</option><option value="4">Four</option><op
tion value="5">Five</option></s
elect></td
>
<td width="9%" height="1">
<input type="Text" Name="Total3" size="4" Value="0" readonly></td>
</tr>
<%
objrsCF.Movenext
Loop
%>
</table>
<p>
<a href="Points.asp">Select Another Team</a></td>
<td width="45" height="438" valign="top" rowspan="3"> </td>
</table>
</tr>
</body>
</html>
Any help would be much appreciated!
Matt