Checking numeric field of array input on client side, Help

I have this form that checks to make sure a radio button is selected before submission, how could I update it to check that the points range is valid in the same function. The javascript function is checkform(). I added the points field and verify it on the server side after submit, but would like to verify it first on the client-side to save user headache but I know very little about java.

[php]<?php

// Report all PHP errors
error_reporting(-1);

require_once(‘includes/application_top.php’);
require(‘includes/classes/team.php’);

if ($_POST[‘action’] == ‘Submit’) {

$week = $_POST['week'];
$cutoffDateTime = getCutoffDateTime($week);
  $res = 0;
$i = $_POST['numgames'];
$exp = $_POST['numexpired'];
$firstgameID = $_POST['firstgameID'];
$lastgameID = $firstgameID + $i; 
  $possible = array();

echo $exp;
if ($exp == 0) {
for ($poss = 0; $poss < $i; $poss++){$possible[$poss] = $poss+1;};

      for ($poss=0; $poss<$i; $poss++){
		for ($g=$firstgameID; $g<$lastgameID; $g++) {
			$pts = $_POST['points' . $g];
			
            if ($pts < 1 or $pts > $i){$res++;}
			if ($possible[$poss] == $pts ){$res++; $possible[$poss] = 0;}
			}}

}
if ($exp == 1) { $i–; $firstgameID++;
for ($poss = 0; $poss < $i; $poss++){$possible[$poss] = $poss+1;};

      for ($poss=0; $poss<$i; $poss++){
		for ($g=$firstgameID; $g<$lastgameID; $g++) {
			$pts = $_POST['points' . $g];
			if ($pts < 1 or $pts > $i){$res++;}
			if ($possible[$poss] == $pts){$res++; $possible[$poss] = 0; }
			}}

//update summary table 
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";


mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());


//loop through non-expire weeks and update picks points is one
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
               
		$pts = (int)$_POST['points' . $result['gameID']] ;
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "');";
      			mysql_query($sql) or die('Error inserting pick: ' . mysql_error()); 

	}

}
//

if ($res == $i){

//update summary table
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";


mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());


//loop through non-expire weeks and update picks
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
               
		$pts = (int)$_POST['points' . $result['gameID']] ;
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID, points) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "', " . $pts . ");";
      			mysql_query($sql) or die('Error inserting pick: ' . mysql_error()); 

	}

}
}
}
if (!($res == $i)){echo ‘

ERROR POINTS ARE NOT 1 THROUGH ’ . $i . ’ RE-ENTER POINTS CORRECTLY
OR YOU WILL ONLY GET 1 POINT PER GAME
(Or your original valid Points picks)

’;}

        header('Location: results.php?week=' . $_POST['week']);

} else {
$week = (int)$_GET[‘week’];
if (empty($week)) {
//get current week
$week = (int)getCurrentWeek();
}
$cutoffDateTime = getCutoffDateTime($week);
$firstGameTime = getFirstGameTime($week);
}

include(‘includes/header.php’);
include(‘includes/column_right.php’);

//display week nav
$sql = "select distinct weekNum from " . $db_prefix . “schedule order by weekNum;”;
$query = mysql_query($sql);
$weekNav = '

Go to week: ';
$i = 0;
while ($result = mysql_fetch_array($query)) {
if ($i > 0) $weekNav .= ’ | ';
if ($week !== (int)$result[‘weekNum’]) {
$weekNav .= ‘’ . $result[‘weekNum’] . ‘’;
} else {
$weekNav .= $result[‘weekNum’];
}
$i++;
}
$weekNav .= ‘
’ . “\n”;
echo $weekNav;
?>
			<h2>Week <?php echo $week; ?> - Make Your Picks:</h2>
			<p>Make your picks below by clicking on the team helmet or checking the radio buttons to the right.</p>
			<script type="text/javascript">
			function checkform() {
				//make sure all picks have a checked value
				var f = document.entryForm;
				var allChecked = true;
				var allR = document.getElementsByTagName('input');
				for (var i=0; i < allR.length; i++) {
					if(allR[i].type == 'radio') {
						if (!radioIsChecked(allR[i].name)) {
							allChecked = false;
						}
					}      
			    }
			    if (!allChecked) {
					return confirm('One or more picks are missing for the current week.  Do you wish to submit anyway?');
				}
				return true;
			}
			function radioIsChecked(elmName) {
				var elements = document.getElementsByName(elmName);
				for (var i = 0; i < elements.length; i++) {
					if (elements[i].checked) {
						return true;
					}
				}
				return false;
			}
			</script>
<div style="float: right; width: 270px; margin-right: 10px"><?php include('includes/comments.php'); ?></div>
<?php
//get existing picks
$picks = getUserPicks($week, $user->userID);
$points = array();
$points = $picks;

//get show picks status
$sql = "select * from " . $db_prefix . "picksummary where weekNum = " . $week . " and userID = " . $user->userID . ";";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	$result = mysql_fetch_array($query);
	$showPicks = (int)$result['showPicks'];
} else {
	$showPicks = 1;
}

//display schedule for week
   $exp=0;
$sql = "select s.*, (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > gameTimeEastern or DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > '" . $cutoffDateTime . "')  as expired ";
$sql .= "from " . $db_prefix . "schedule s ";
$sql .= "inner join " . $db_prefix . "teams ht on s.homeID = ht.teamID ";
$sql .= "inner join " . $db_prefix . "teams vt on s.visitorID = vt.teamID ";
$sql .= "where s.weekNum = " . $week . " ";
$sql .= "order by s.gameTimeEastern, s.gameID";
//echo $sql;
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	echo '<form name="entryForm" action="entry_formweighted.php" method="post" onsubmit="return checkform();">' . "\n";
	echo '<input type="hidden" name="week" value="' . $week . '" />' . "\n";
	echo '<table cellpadding="4" cellspacing="0" class="table1">' . "\n";
	//echo '	<tr><th>Home</th><th>Visitor</th><th align="left">Game</th><th>Time / Result</th><th>Your Pick</th></tr>' . "\n";
	$i = 0;
	while ($result = mysql_fetch_array($query)) {
		$homeTeam = new team($result['homeID']);
		$visitorTeam = new team($result['visitorID']);
		$rowclass = (($i % 2 == 0) ? ' class="altrow"' : '');
		//$pickExpired = ((date("U") > strtotime($result['gameTimeEastern'])) ? true : false);
		echo '		<tr' . $rowclass . '>' . "\n";
		echo '			<td align="center">' . "\n";
		echo '				<table width="100%" border="0" cellpadding="2" cellspacing="0" class="nostyle">' . "\n";
		echo '					<tr valign="middle">' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $visitorTeam->teamID . '"><img src="images/helmets_big/' . strtolower($visitorTeam->teamID) . '1.gif" onclick="document.entryForm.game' . $result['gameID'] . '[0].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $visitorTeam->city . ' ' . $visitorTeam->team . '</b><br />Record: ' . getTeamRecord($visitorTeam->teamID) . '<br />Streak: ' . getTeamStreak($visitorTeam->teamID) . '</span></td>' . "\n";
		echo '						<td align="center">at</td>' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $homeTeam->teamID . '"><img src="images/helmets_big/' . strtolower($homeTeam->teamID) . '2.gif" onclick="document.entryForm.game' . $result['gameID'] . '[1].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $homeTeam->city . ' ' . $homeTeam->team . '</b><br />Record: ' . getTeamRecord($homeTeam->teamID) . '<br />Streak: ' . getTeamStreak($homeTeam->teamID) . '</span></td>' . "\n";
		echo '					</tr>' . "\n";
		if (strlen($result['homeScore']) > 0 && strlen($result['visitorScore']) > 0) {
			//if score is entered, show score
			$scoreEntered = TRUE;

			echo '					<tr><td colspan="3" align="center"><b>Final: ' . $result['visitorScore'] . ' - ' . $result['homeScore'] . '</b></td></tr>' . "\n";
		} else {
			//else show time of game
			echo '					<tr><td colspan="3" align="center">' . date('D n/j g:i a', strtotime($result['gameTimeEastern'])) . ' ET</td></tr>' . "\n";
		}
		echo '				</table>' . "\n";
		echo '			</td>' . "\n";
		echo '			<td align="left"><b>Your Pick:</b><br />' . "\n";
              if ($result['expired']) { $exp++;}
		if (!$result['expired']) {
			//if game is not expired, show pick
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $visitorTeam->teamID . '" id="' . $result['gameID'] . $visitorTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $visitorTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $visitorTeam->teamID . '">' . $visitorTeam->teamName . '</label><br />' . "\n";
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $homeTeam->teamID . '" id="' . $result['gameID'] . $homeTeam->teamID . '"' . (( $picks[$result['gameID']]['pickID'] == $homeTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $homeTeam->teamID . '">' . $homeTeam->teamName . '</label><br />' . "\n";
            echo '			<input type="text" min="1" max="15" length="2" name="points' . $result['gameID'] . '" value="' . $picks[$result['gameID']]['points']  . '"/><br /><B>Confidence Points</B>' . "\n";				
             $lastgameID = $result['gameID'];

			
		} else {
			//else show locked pick
			$pickID = getPickID($result['gameID'], $user->userID);
			if (!empty($pickID)) {
				$statusImg = '';
				$pickTeam = new team($pickID);
				$pickLabel = $pickTeam->teamName;
                          
			} else {
				$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
				$pickLabel = 'None Selected';
			}
			if ($scoreEntered) {
				//set status of pick (correct, incorrect)

$winnerid = ‘’;
if ($result[‘homeScore’] > $result[‘visitorScore’]) { $winnerid = $homeTeam->teamID; }else { $winnerid = $visitorTeam->teamID;}

				if ($pickID == $winnerid) {
					$statusImg = '<img src="images/check_16x16.png" width="16" height="16" alt="" />';
                                $pickpoints = $picks[$result['gameID']]['points'];
				} else {
					$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
					$pickpoints = 0;
				}
			}
			echo '			' . $statusImg . ' ' . $pickLabel . "\n";
			
                    echo '                 <BR><B>Points/Possible: ' . $pickpoints. ' / ' . $picks[$result['gameID']]['points'] . '</B>' ."\n";

		}
		echo '			</td>' . "\n";
		echo '		</tr>' . "\n";
		$i++;
	}
	echo '</table>' . "\n";
        echo $i;
	$firstgameID = $lastgameID - $i + 1;
	echo '<input type="hidden" name="firstgameID" value="' . $firstgameID . '" />' . "\n";
	echo '<input type="hidden" name="numgames" value="' . $i . '" />' . "\n";
	echo '<input type="hidden" name="numexpired" value="' . $exp . '" />' . "\n";



	if ($exp == 0) {
        echo '<p> Enter 1 through ' . $i . ' in the confidence points fields for each game.</p>';}
        if ($exp == 1) { $i--;
	echo '<p> Enter 1 through ' . $i . ' in the confidence points fields for each game.</p>';}

	echo '<p><input type="checkbox" name="showPicks" id="showPicks" value="1"' . (($showPicks) ? ' checked="checked"' : '') . ' /> <label for="showPicks">Allow others to see my picks</label></p>' . "\n";
	echo '<p><input type="submit" name="action" value="Submit" /></p>' . "\n";
	echo '</form>' . "\n";
}
?>
<?php include('includes/footer.php'); ?>[/php]

You can do something similar to what you have, since you don’t have predefined field names. I didn’t validate this code but it should work, I’m comparing the first 6 letters of all input boxes for points, because that will tell me if it’s a points field, since the game ID is part of the name and we don’t know that ahead of time. Then we check the length and it’s 0, we know their is no input. You might wan’t it add a check to see if it’s numeric or within a certain range, but this should get you started.

[php]for (var i=0; i < allR.length; i++) {
if(allR[i].type == ‘radio’) {
if (!radioIsChecked(allR[i].name)) {
allChecked = false;
}
if(substr(allR[i].name,6) == ‘points’) {
if (allR[i].value.length = 0)) {
allChecked = false;
}
} [/php]

Something like this?

[php]if(allR[i].type == ‘radio’) {
if (!radioIsChecked(allR[i].name)) {
allChecked = false;
}
}
if(substr(allR[i].name,6) == ‘points’) {
if ((allR[i].value.length = 0) || (allR[i].value > 1) || allR[i.value > 16]) {
allChecked = false;}
} }
[/php]

Now it isn’t even checking for the radio buttons to be picked, what did I do?

[php]<?php

// Report all PHP errors
error_reporting(-1);

require_once(‘includes/application_top.php’);
require(‘includes/classes/team.php’);

if ($_POST[‘action’] == ‘Submit’) {

$week = $_POST['week'];
$cutoffDateTime = getCutoffDateTime($week);
  $res = 0;
$i = $_POST['numgames'];
$exp = $_POST['numexpired'];
$firstgameID = $_POST['firstgameID'];
$lastgameID = $firstgameID + $i; 
  $possible = array();

echo $exp;
if ($exp == 0) {
for ($poss = 0; $poss < $i; $poss++){$possible[$poss] = $poss+1;};

      for ($poss=0; $poss<$i; $poss++){
		for ($g=$firstgameID; $g<$lastgameID; $g++) {
			$pts = $_POST['points' . $g];
			
            if ($pts < 1 or $pts > $i){$res++;}
			if ($possible[$poss] == $pts ){$res++; $possible[$poss] = 0;}
			}}

}
if ($exp == 1) { $i–; $firstgameID++;
for ($poss = 0; $poss < $i; $poss++){$possible[$poss] = $poss+1;};

      for ($poss=0; $poss<$i; $poss++){
		for ($g=$firstgameID; $g<$lastgameID; $g++) {
			$pts = $_POST['points' . $g];
			if ($pts < 1 or $pts > $i){$res++;}
			if ($possible[$poss] == $pts){$res++; $possible[$poss] = 0; }
			}}

//update summary table 
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";


mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());


//loop through non-expire weeks and update picks points is one
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
               
		$pts = (int)$_POST['points' . $result['gameID']] ;
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "');";
      			mysql_query($sql) or die('Error inserting pick: ' . mysql_error()); 

	}

}
//

if ($res == $i){

//update summary table
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";


mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());


//loop through non-expire weeks and update picks
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
               
		$pts = (int)$_POST['points' . $result['gameID']] ;
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID, points) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "', " . $pts . ");";
      			mysql_query($sql) or die('Error inserting pick: ' . mysql_error()); 

	}

}
}
}
if (!($res == $i)){echo ‘

ERROR POINTS ARE NOT 1 THROUGH ’ . $i . ’ RE-ENTER POINTS CORRECTLY
OR YOU WILL ONLY GET 1 POINT PER GAME
(Or your original valid Points picks)

’;}

        header('Location: results.php?week=' . $_POST['week']);

} else {
$week = (int)$_GET[‘week’];
if (empty($week)) {
//get current week
$week = (int)getCurrentWeek();
}
$cutoffDateTime = getCutoffDateTime($week);
$firstGameTime = getFirstGameTime($week);
}

include(‘includes/header.php’);
include(‘includes/column_right.php’);

//display week nav
$sql = "select distinct weekNum from " . $db_prefix . “schedule order by weekNum;”;
$query = mysql_query($sql);
$weekNav = '

Go to week: ';
$i = 0;
while ($result = mysql_fetch_array($query)) {
if ($i > 0) $weekNav .= ’ | ';
if ($week !== (int)$result[‘weekNum’]) {
$weekNav .= ‘’ . $result[‘weekNum’] . ‘’;
} else {
$weekNav .= $result[‘weekNum’];
}
$i++;
}
$weekNav .= ‘
’ . “\n”;
echo $weekNav;
?>
			<h2>Week <?php echo $week; ?> - Make Your Picks:</h2>
			<p>Make your picks below by clicking on the team helmet or checking the radio buttons to the right.</p>
			<script type="text/javascript">
			function checkform() {
				//make sure all picks have a checked value
				var f = document.entryForm;
				var allChecked = true;
				var allR = document.getElementsByTagName('input');
				for (var i=0; i < allR.length; i++) {
					if(allR[i].type == 'radio') {
						if (!radioIsChecked(allR[i].name)) {
							allChecked = false;
						}
					}
                                      if(substr(allR[i].name,6) == 'points') {
							if ((allR[i].value.length == 0) || (allR[i].value > 1) || (allR[i].value > 16])) {
									allChecked = false;}
				 } 						}

  
			    
			    if (!allChecked) {
					return confirm('One or more picks are missing for the current week.  Do you wish to submit anyway?');
				}
				return true;
			}
			function radioIsChecked(elmName) {
				var elements = document.getElementsByName(elmName);
				for (var i = 0; i < elements.length; i++) {
					if (elements[i].checked) {
						return true;
					}
				}
				return false;
			}
			</script>
<div style="float: right; width: 270px; margin-right: 10px"><?php include('includes/comments.php'); ?></div>
<?php
//get existing picks
$picks = getUserPicks($week, $user->userID);
$points = array();
$points = $picks;

//get show picks status
$sql = "select * from " . $db_prefix . "picksummary where weekNum = " . $week . " and userID = " . $user->userID . ";";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	$result = mysql_fetch_array($query);
	$showPicks = (int)$result['showPicks'];
} else {
	$showPicks = 1;
}

//display schedule for week
   $exp=0;
$sql = "select s.*, (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > gameTimeEastern or DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > '" . $cutoffDateTime . "')  as expired ";
$sql .= "from " . $db_prefix . "schedule s ";
$sql .= "inner join " . $db_prefix . "teams ht on s.homeID = ht.teamID ";
$sql .= "inner join " . $db_prefix . "teams vt on s.visitorID = vt.teamID ";
$sql .= "where s.weekNum = " . $week . " ";
$sql .= "order by s.gameTimeEastern, s.gameID";
//echo $sql;
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	echo '<form name="entryForm" action="entry_formweighted.php" method="post" onsubmit="return checkform();">' . "\n";
	echo '<input type="hidden" name="week" value="' . $week . '" />' . "\n";
	echo '<table cellpadding="4" cellspacing="0" class="table1">' . "\n";
	//echo '	<tr><th>Home</th><th>Visitor</th><th align="left">Game</th><th>Time / Result</th><th>Your Pick</th></tr>' . "\n";
	$i = 0;
	while ($result = mysql_fetch_array($query)) {
		$homeTeam = new team($result['homeID']);
		$visitorTeam = new team($result['visitorID']);
		$rowclass = (($i % 2 == 0) ? ' class="altrow"' : '');
		//$pickExpired = ((date("U") > strtotime($result['gameTimeEastern'])) ? true : false);
		echo '		<tr' . $rowclass . '>' . "\n";
		echo '			<td align="center">' . "\n";
		echo '				<table width="100%" border="0" cellpadding="2" cellspacing="0" class="nostyle">' . "\n";
		echo '					<tr valign="middle">' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $visitorTeam->teamID . '"><img src="images/helmets_big/' . strtolower($visitorTeam->teamID) . '1.gif" onclick="document.entryForm.game' . $result['gameID'] . '[0].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $visitorTeam->city . ' ' . $visitorTeam->team . '</b><br />Record: ' . getTeamRecord($visitorTeam->teamID) . '<br />Streak: ' . getTeamStreak($visitorTeam->teamID) . '</span></td>' . "\n";
		echo '						<td align="center">at</td>' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $homeTeam->teamID . '"><img src="images/helmets_big/' . strtolower($homeTeam->teamID) . '2.gif" onclick="document.entryForm.game' . $result['gameID'] . '[1].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $homeTeam->city . ' ' . $homeTeam->team . '</b><br />Record: ' . getTeamRecord($homeTeam->teamID) . '<br />Streak: ' . getTeamStreak($homeTeam->teamID) . '</span></td>' . "\n";
		echo '					</tr>' . "\n";
		if (strlen($result['homeScore']) > 0 && strlen($result['visitorScore']) > 0) {
			//if score is entered, show score
			$scoreEntered = TRUE;

			echo '					<tr><td colspan="3" align="center"><b>Final: ' . $result['visitorScore'] . ' - ' . $result['homeScore'] . '</b></td></tr>' . "\n";
		} else {
			//else show time of game
			echo '					<tr><td colspan="3" align="center">' . date('D n/j g:i a', strtotime($result['gameTimeEastern'])) . ' ET</td></tr>' . "\n";
		}
		echo '				</table>' . "\n";
		echo '			</td>' . "\n";
		echo '			<td align="left"><b>Your Pick:</b><br />' . "\n";
              if ($result['expired']) { $exp++;}
		if (!$result['expired']) {
			//if game is not expired, show pick
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $visitorTeam->teamID . '" id="' . $result['gameID'] . $visitorTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $visitorTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $visitorTeam->teamID . '">' . $visitorTeam->teamName . '</label><br />' . "\n";
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $homeTeam->teamID . '" id="' . $result['gameID'] . $homeTeam->teamID . '"' . (( $picks[$result['gameID']]['pickID'] == $homeTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $homeTeam->teamID . '">' . $homeTeam->teamName . '</label><br />' . "\n";
            echo '			<input type="text" min="1" max="15" length="2" name="points' . $result['gameID'] . '" value="' . $picks[$result['gameID']]['points']  . '"/><br /><B>Confidence Points</B>' . "\n";				
             $lastgameID = $result['gameID'];

			
		} else {
			//else show locked pick
			$pickID = getPickID($result['gameID'], $user->userID);
			if (!empty($pickID)) {
				$statusImg = '';
				$pickTeam = new team($pickID);
				$pickLabel = $pickTeam->teamName;
                          
			} else {
				$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
				$pickLabel = 'None Selected';
			}
			if ($scoreEntered) {
				//set status of pick (correct, incorrect)

$winnerid = ‘’;
if ($result[‘homeScore’] > $result[‘visitorScore’]) { $winnerid = $homeTeam->teamID; }else { $winnerid = $visitorTeam->teamID;}

				if ($pickID == $winnerid) {
					$statusImg = '<img src="images/check_16x16.png" width="16" height="16" alt="" />';
                                $pickpoints = $picks[$result['gameID']]['points'];
				} else {
					$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
					$pickpoints = 0;
				}
			}
			echo '			' . $statusImg . ' ' . $pickLabel . "\n";
			
                    echo '                 <BR><B>Points/Possible: ' . $pickpoints. ' / ' . $picks[$result['gameID']]['points'] . '</B>' ."\n";

		}
		echo '			</td>' . "\n";
		echo '		</tr>' . "\n";
		$i++;
	}
	echo '</table>' . "\n";
        echo $i;
	$firstgameID = $lastgameID - $i + 1;
	echo '<input type="hidden" name="firstgameID" value="' . $firstgameID . '" />' . "\n";
	echo '<input type="hidden" name="numgames" value="' . $i . '" />' . "\n";
	echo '<input type="hidden" name="numexpired" value="' . $exp . '" />' . "\n";



	if ($exp == 0) {
        echo '<p> Enter 1 through ' . $i . ' in the confidence points fields for each game.</p>';}
        if ($exp == 1) { $i--;
	echo '<p> Enter 1 through ' . $i . ' in the confidence points fields for each game.</p>';}

	echo '<p><input type="checkbox" name="showPicks" id="showPicks" value="1"' . (($showPicks) ? ' checked="checked"' : '') . ' /> <label for="showPicks">Allow others to see my picks</label></p>' . "\n";
	echo '<p><input type="submit" name="action" value="Submit" /></p>' . "\n";
	echo '</form>' . "\n";
}
?>
<?php include('includes/footer.php'); ?>[/php]

I didn’t look at your entire script but you have a bracker that don’t below after the 16

Change:

[php]if ((allR[i].value.length == 0) || (allR[i].value > 1) || (allR[i].value > 16])) {[/php]

To:

[php]if ((allR[i].value.length == 0) || (allR[i].value > 1) || (allR[i].value > 16)) {[/php]

If you’re a sports fan, you should look at mlbboards.com, sign up and post an intro and they (I) will give you $50 MLBB Cash to use towards the sports book there.

Yeah I had fixed the missing bracket and it still isn’t working at all.

Is there a way to call a function as soon as they move from the field (before submit) to the next field?

I could dynamically put a script with the variable name filled in by PHP for each line of input.

Is there a way to call a function as soon as they move from the field (before submit) to the next field?

Yes you can do that in java-script…

You can add at to the onblur event of the input tag

http://www.w3schools.com/tags/ref_eventattributes.asp

<input type=text" onblur=“javascriptfunction;”>

Awesome, gonna give that a try.

Changed the code to this
[php] Add Comment:

Subject:

Comment:

[/code]

New Orleans Saints
Record: 5-1-0
Streak: L 1
at
Atlanta Falcons
Record: 2-4-0
Streak: W 1
Thu 11/21 8:25 pm ET
Your Pick:
New Orleans Saints
Atlanta Falcons

Confidence Points

Pittsburgh Steelers
Record: 2-4-0
Streak: W 2
at
Cleveland Browns
Record: 3-4-0
Streak: L 2
Sun 11/24 1:00 pm ET
Your Pick:
Pittsburgh Steelers
Cleveland Browns

Confidence Points

Tampa Bay Buccaneers
Record: 0-6-0
Streak: L 6
at
Detroit Lions
Record: 4-3-0
Streak: L 1
Sun 11/24 1:00 pm ET
Your Pick:
Tampa Bay Buccaneers
Detroit Lions

Confidence Points

Minnesota Vikings
Record: 1-5-0
Streak: L 2
at
Green Bay Packers
Record: 4-2-0
Streak: W 3
Sun 11/24 1:00 pm ET
Your Pick:
Minnesota Vikings
Green Bay Packers

Confidence Points

Do you use Jquery? if so we can simplify this a lot…

I tried pasting some jquery examples in and had no luck but would be glad to try anything at this point.

I tried php dumping individual functions for each input of the array and can’t get that to work.

here is what I put in the php
[php] if (!$result[‘expired’]) {
//if game is not expired, show pick
?>

			<?php
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $visitorTeam->teamID . '" id="' . $result['gameID'] . $visitorTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $visitorTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $visitorTeam->teamID . '">' . $visitorTeam->teamName . '</label><br />' . "\n";
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $homeTeam->teamID . '" id="' . $result['gameID'] . $homeTeam->teamID . '"' . (( $picks[$result['gameID']]['pickID'] == $homeTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $homeTeam->teamID . '">' . $homeTeam->teamName . '</label><br />' . "\n";
            echo '			<input type="text"  name="points' . $result['gameID'] . '" value="' . $picks[$result['gameID']]['points']  . '" onblur="verifypoints' . $result['gameID'] . '();"/><br /><B>Confidence Points</B>' . "\n";				
             $lastgameID = $result['gameID'];

[/php]

And here is what it compiled, looks like it should work, but it does nothing.

[code]


New Orleans Saints
Record: 5-1-0
Streak: L 1
at
Atlanta Falcons
Record: 2-4-0
Streak: W 1
Thu 11/21 8:25 pm ET
Your Pick:
						<input type="radio" name="game163" value="NO" id="163NO" /> <label for="163NO">New Orleans Saints</label><br />
		<input type="radio" name="game163" value="ATL" id="163ATL" /> <label for="163ATL">Atlanta Falcons</label><br />
		<input type="text"  name="points163" value="" onblur="verifypoints163();"/><br /><B>Confidence Points</B>
		</td>
	</tr>
	<tr>
		<td align="center">
			<table width="100%" border="0" cellpadding="2" cellspacing="0" class="nostyle">
				<tr valign="middle">
					<td align="center"><label for="164PIT"><img src="images/helmets_big/pit1.gif" onclick="document.entryForm.game164[0].checked=true;" /></label><br /><span style="font-size: 9px;"><b>Pittsburgh Steelers</b><br />Record: 2-4-0<br />Streak: W 2</span></td>
					<td align="center">at</td>
					<td align="center"><label for="164CLE"><img src="images/helmets_big/cle2.gif" onclick="document.entryForm.game164[1].checked=true;" /></label><br /><span style="font-size: 9px;"><b>Cleveland Browns</b><br />Record: 3-4-0<br />Streak: L 2</span></td>
				</tr>
				<tr><td colspan="3" align="center">Sun 11/24 1:00 pm ET</td></tr>
			</table>
		</td>
		<td align="left"><b>Your Pick:</b><br />
			<script>

function verifypoints164()
{
var x=document.entryForm.points164.value;
if (x < 1) || (x>15){alert( “Please enter a number between 1 and 1” );}
}

						<input type="radio" name="game164" value="PIT" id="164PIT" /> <label for="164PIT">Pittsburgh Steelers</label><br />
		<input type="radio" name="game164" value="CLE" id="164CLE" /> <label for="164CLE">Cleveland Browns</label><br />
		<input type="text"  name="points164" value="" onblur="verifypoints164();"/><br /><B>Confidence Points</B>
		</td>
	</tr>[/code]

Apparently it did not like my or within the if statement. I separated it into 2 separate if statements and it works now.

That’s Awesome! I bet JimL’s jQuery solution will rock though.

Yeah, I am watching a 30 day youtube thing on jquery. I watched one on java, between that and you guys help I figured what to do to fix it.

Is there a query to check if an integer? If they enter numbers less than 1 or greater than the number of games played, it alerts them. But if they enter any characters it does nothing. Would like to add an if statement see if it is an integer.

I don’t understand how I would use parseint to get it done. Looked at many examples but wasn’t sure how to adapt it to my needs.

You can do something like this.

if( Math.floor(gamesplayed) == id && $.isNumeric(gamesplayed) && gamesplayed > 1) alert(‘yes its an int!’);

OK I’m doing something wrong with what you posted.

I did this
[php] [/php]

which compiled this

[code] [/code]

And when I run it and if I type in ggg it alerts me of the ggg as pts but does not recognize the ! isnumeric and give me that alert that it needs to be a number.

Is my syntax incorrect?

Try alerting some of the examples show here to see if it’s working properly.

http://api.jquery.com/jQuery.isNumeric/

I tried this

if $.isNumeric( 16 ){alert (“jquery works”);}
I tried this
if ($.isNumeric( 16 )){alert (“jquery works”);}

It ends the script and doesn’t proceed with everything after it and does not give the alert.

Did you include a reference to the latest jQuery Library?

http://jquery.com/

You can download it and you have to reference it for jQuery to work…

Yeah I put this in there, and verified that it is uploaded.

Sponsor our Newsletter | Privacy Policy | Terms of Service