ドロップダウンフィールドで選択した値に応じてファンタジーフットボールのスコアを計算するマルチタブアプリを作成しています。6つのタブのうち5つで動作していますが、6番目のタブで動作させることができません。私は新鮮な目が私が欠けている何かを見つけることを望んでいました:
<?php
// contact to database
$connect = mysql_connect("localhost", "dariia", "celtic03") or die ("Error , check your server connection.");
mysql_select_db("football");
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
function calcTFP(e) {
if(e) e.preventDefault();
var $tds, Sacks, Int_Caught, Def_TD, ST_TD, Shutouts, TFP;
$("tbody#dst tr").each(function() {
$tds = $(this).find("td");
Sacks = Number($tds.eq(1).text());
Int_Caught = Number($tds.eq(2).text());
Def_TD = Number($tds.eq(3).text());
ST_TD = Number($tds.eq(4).text());
Shutouts = Number($tds.eq(5).text());
TFP = Number($s_sacks_pts.val()) * Sacks;
TFP += Number($s_int_caught_pts.val()) * Int_Caught;
TFP += Number($s_def_td_pts.val()) * Def_TD;
TFP += Number($s_st_td_pts.val()) * ST_TD;
TFP += Number($s_shut_pts.val()) * Shutouts;
$tds.eq(6).text(TFP.toFixed(2));//display calculated points in row's TFP column
});
}
//Sacks
var $s_sacks_pts = $("#s_sacks_pts").on('change', calcTFP);
//Int Caught
var $s_int_caught_pts = $("#s_int_caught_pts").on('change', calcTFP);
//Defense TDs
var $s_def_td_pts = $("#s_def_td_pts").on('change', calcTFP);
//Special Teams TDs
var $s_st_td_pts = $("#s_st_td_pts").on('change', calcTFP);
//Shutouts
var $s_shutouts_pts = $("#s_shutouts_pts").on('change', calcTFP);
calcTFP();//initial calculation on page load
});
</script>
<form id="calc">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="padding-right:33px"><strong>Sacks:</strong><br />
<div style="float:left ; text-align:center">
<select id="s_sacks_pts">
<option value="0">0 pts</option>
<option value="1">1 pt</option>
<option value="2">2 pts</option>
<option value="3">3 pts</option>
<option value="4">4 pts</option>
<option value="5">5 pts</option>
<option value="6" selected>6 pts</option>
<option value="7">7 pts</option>
<option value="8">8 pts</option>
<option value="9">9 pts</option>
<option value="10">10 pts</option>
</select>
</div>
<div style="float:left ; padding:9px 0px 0px 5px">per Sack</div>
</td>
<td style="padding-right:33px"><strong>Int Caught</strong><br />
<div style="float:left ; text-align:center">
<select id="s_int_caught_pts">
<option value="0">0 pts</option>
<option value="1">1 pt</option>
<option value="2">2 pts</option>
<option value="3">3 pts</option>
<option value="4">4 pts</option>
<option value="5">5 pts</option>
<option value="6" selected>6 pts</option>
<option value="7">7 pts</option>
<option value="8">8 pts</option>
<option value="9">9 pts</option>
<option value="10">10 pts</option>
</select>
</div>
<div style="float:left ; padding:9px 0px 0px 5px">per Int Caught</div>
</td>
<td style="padding-right:33px"><strong>Def TDs:</strong><br />
<div style="float:left ; text-align:center">
<select id="s_def_td_pts">
<option value="0" selected>0 pts</option>
<option value="1">1 pt</option>
<option value="2">2 pts</option>
<option value="3">3 pts</option>
<option value="4">4 pts</option>
<option value="5">5 pts</option>
<option value="6">6 pts</option>
<option value="7">7 pts</option>
<option value="8">8 pts</option>
<option value="9">9 pts</option>
<option value="10">10 pts</option>
</select>
</div>
<div style="float:left ; padding:9px 5px 0px 5px">per TD</div>
</td>
<td style="padding-right:33px"><strong>ST TDs:</strong><br />
<div style="float:left ; text-align:center">
<select id="s_st_td_pts">
<option value="0" selected>0 pts</option>
<option value="1">1 pt</option>
<option value="2">2 pts</option>
<option value="3">3 pts</option>
<option value="4">4 pts</option>
<option value="5">5 pts</option>
<option value="6">6 pts</option>
<option value="7">7 pts</option>
<option value="8">8 pts</option>
<option value="9">9 pts</option>
<option value="10">10 pts</option>
</select>
</div>
<div style="float:left ; padding:9px 5px 0px 5px">per TD</div>
</td>
<td style="padding-right:33px"><strong>Shutouts:</strong><br />
<div style="float:left ; text-align:center">
<select id="s_shutouts_pts">
<option value="0" selected>0 pts</option>
<option value="1">-1 pt</option>
<option value="2">-2 pts</option>
<option value="3">-3 pts</option>
<option value="4">-4 pts</option>
<option value="5">-5 pts</option>
<option value="6">-6 pts</option>
<option value="7">-7 pts</option>
<option value="8">-8 pts</option>
<option value="9">-9 pts</option>
<option value="10">-10 pts</option>
</select>
</div>
<div style="float:left ; padding:9px 5px 0px 5px">per TD</div>
</td>
</tr>
</table>
</form>
<p>* Note: You can sort Def / ST projections by any stat you like. Just click on the stat name to sort.</p>
<table id="table-def" class="tablesorter" cellspacing="0" cellpadding="5" border="1" width="630">
<thead>
<tr style="text-align:center">
<th>Team</th>
<th>Sacks</th>
<th>Int</th>
<th>Def TD</th>
<th>ST TD</th>
<th>Shutouts</th>
<th>TFP</th>
</tr>
</thead>
<tbody id="dst">
<?php
$result = mysql_query("SELECT Team, Sacks, Int_Caught, Def_TD, ST_TD, Shutouts, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'Def' ORDER BY Pass_Yds DESC;");
while($row = mysql_fetch_array($result))
{
echo "<tr style=\"text-align:center\"><td>{$row['Team']}</td>";
echo "<td>{$row['Sacks']}</td>";
echo "<td>{$row['Int_Caught']}</td>";
echo "<td>{$row['Def_TD']}</td>";
echo "<td>{$row['ST_TD']}</td>";
echo "<td>{$row['Shutouts']}</td>";
echo "<td>{$row['Total_Fantasy_Pts']}</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>