Created
September 23, 2016 14:49
-
-
Save MikSDigital/1a6feec29a00648e68fca7127f829503 to your computer and use it in GitHub Desktop.
sticky dropdown (Sebastian Sulinski)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getAge($label, $limit=150) { | |
$out = "<select name=\"{$label}\" id=\"{$label}\" class=\"sel\">"; | |
for($i=0; $i <= $limit; $i++) { | |
$out .= "<option value=\"{$i}\""; | |
$out .= stickyDropdown($label, $i); | |
$out .= ">{$i}</option>"; | |
} | |
$out .= "</select>"; | |
return $out; | |
} | |
function stickyDropdown($par, $value) { | |
if(isset($_POST[$par]) && $_POST[$par] == $value) { | |
return " selected=\"selected\""; | |
} elseif (isset($_SESSION[$par]) && $_SESSION[$par] == $value) { | |
return " selected=\"selected\""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment