Return to Snippet

Revision: 48251
at June 27, 2011 19:55 by brownrl


Initial Code
<?php

// Function Get Check Box
//
// Make a simple checkbox for a form
//
// $name -> the name and id of the html checkBox
// $style -> optional styling to add in to the check box
// 
// works with _POST, if the box was checked it will remain checked on repost or reload
//
function getCheckBox( $name , $style = "" )
{
	$_POST[$name] = strtolower( $_POST[$name] );
	$on = ( $_POST[$name] == "on" ) ? " checked " : ""; // this is done cause some browsers... like to use 'On' instead of 'on'
	if( strlen( $style ) )
	{
		$style = "style=\"".$style."\"";
	}
	
	
	return "<input ".$style." type=\"checkbox\" id=\"".$name."\" name=\"".$name."\"".$on."/>";
}

?>

Initial URL
http://www.itsgotto.be/cv.php

Initial Description
Simple simple simple function to make a checkbox for a form. Retains checked status.

Initial Title
PHP getCheckBox

Initial Tags
forms

Initial Language
PHP