Ok I have the following function that creates a select menu so a user can choose a state.
function state_selection()
{
$str = '<select name="state">';
$states = array(
'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
);
foreach ($states as $state_name)
{
$str .= '<option value="'.$state_name.'">'.$state_name.'</option>';
}
$str .= '</select>';
return $str;
}
My question is... This works great if there is just one state selection on that page... but in my form I need the user to select several states, sometimes as many as 12. How can I change the function to be able to reuse it several times within the same form... and still have it send each selection as a seperate variable.