Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/sf.php
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]

if (tempobj.name.substring(0,3)=="req"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("Please fill in the relevant field(s).")
return false
}
else
return true
}



</script>


<?

function listdigits($max, $choosedigit)
{
	if (!$max) { exit; } # Prevent endless loops

	for($i = 1; $i <= $max; $i++) 
	{
		if ($i < 10) { $val = '0' . $i; }
		else { $val = $i; }

		if($i == $choosedigit) { $sel = "selected"; }
		else { $sel = ""; } 

		$makereturn .= "<option $sel value='$val'>$val</option>\n";
    }

	return $makereturn;
}

function listdigits2($max, $choosedigit)
{
	if (!$max) { exit; } # Prevent endless loops

	for($i = 0; $i <= $max; $i++) 
	{
		if ($i < 10) { $val = '0' . $i; }
		else { $val = $i; }

		if($i == $choosedigit) { $sel = "selected"; }
		else { $sel = ""; } 

		$makereturn .= "<option $sel value='$val'>$val</option>\n";
    }

	return $makereturn;
}

function listyears($numyears, $chooseyear, $startyear='')
{
$thisyear="2000";
//	$thisyear = date('Y');

	if ($startyear != '') { $thisyear = $startyear; } else {}

	for($i = $thisyear; $i <= ($thisyear + $numyears); $i++) 
	{
		if($i == $chooseyear) { $sel = "selected"; }
		else { $sel = ""; }

		$makereturn .= "<option $sel value='$i'>$i</option>\n";
    }

	return $makereturn;
}

function durationdifference($startdate, $enddate)
{
	list($syear, $smonth, $sday) = explode("-", $startdate);
	list($eyear, $emonth, $eday) = explode("-", $enddate);

	$startdate = mktime(0,0,0,$smonth,$sday,$syear); // in the form (hours, minutes, seconds, month, day, year) 
	$enddate = mktime(0,0,0,$emonth,$eday,$eyear);
	$timediff = $enddate - $startdate; 

	return ($timediff / (60 * 60 * 24));
}

function formatdate($changedate, $style) 
{
	list($thedate, $thetime) = split(" ", $changedate);
	list($year, $month, $day) = split("-", $thedate);
	list($hour, $minute, $second) = split(":", $thetime);

	if ($style == '1') { $returndate = "$day-$month-$year"; }
	elseif ($style == '2') { $returndate = "$day-$month-$year $hour:$minute"; }

	return $returndate;
}

function listyears2($numyears, $chooseyear, $startyear='')
{
	$thisyear = date('Y');

	if ($startyear != '') { $thisyear = $startyear; } else {}

	for($i = $thisyear; $i <= ($thisyear + $numyears); $i++) 
	{
		if($i == $chooseyear) { $sel = "selected"; }
		else { $sel = ""; }

		$makereturn .= "<option $sel value='$i'>$i</option>\n";
    }

	return $makereturn;
}

?>
Return current item: GolfstatsPHP