Prefilling Selection Lists
<select name="listname"> <option value="php3"<?php if (isset($_POST['listname']) && $_POST['listname'] == 'php3') { echo ' selected="selected"'; } ?>>PHP 3</option> <option value="php4"<?php if (isset($_POST['listname']) && $_POST['listname'] == 'php4') { echo ' selected="selected"'; } ?>>PHP 4</option> <option value="php5"<?php if (isset($_POST['listname']) && $_POST['listname'] == 'php5') { echo ' selected="selected"'; } ?>>PHP 5</option> </select>
The same effect can be implemented using getFormData.inc.php
; then data from the site's cookies is used, if available.
Prefilling Selection Lists
<?php require_once 'getFormData.inc.php'; ?> ... <select name="listname"> <option value="php3"<?php if (getFormDataPOST('listname') == 'php3') { echo ' selected="selected"'; } ?>>PHP 3</option> <option value="php4"<?php if (getFormDataPOST('listname') == 'php4') { echo ' selected="selected"'; } ?>>PHP 4</option> <option value="php5"<?php if (getFormDataPOST('listname') == 'php5') { echo ' selected="selected"'; } ?>>PHP 5</option> </select>
by
updated