Welcome Guest, Not a member yet? Register   Sign In
Set select problem after form validation
#1

[eluser]Dave S[/eluser]
I have a form on which I ask people to enter their birthdate by choosing from a select menu. I am having a problem getting the set_select to work so that the year they have chosen is still selected in case the validation fails. The problem is occurring because I have the years loading in a loop like so:

Code:
<select name="BirthYear">
        <option value="">Year</option>
        &lt;?PHP
            $CurrentYear = date("Y");
            $StartYear = $CurrentYear - 100;
            while ($CurrentYear >= $StartYear) {
                echo "<option value=\"$CurrentYear\"".$this->validation->set_select('BirthYear', '$CurrentYear').">$CurrentYear</option>";
                $CurrentYear--;
            }
        ?&gt;
        </select>

rather than having 100 lines of <option>'s.

I was able to get set_select to work fine for the month values because they are not in a loop. I'm sure it's just something silly that I've done, but the above code does not keep the selected value when the form is submitted and fails validation.

Does anyone have any suggestions? Thanks in advance!


Messages In This Thread
Set select problem after form validation - by El Forum - 06-09-2008, 01:51 PM
Set select problem after form validation - by El Forum - 06-09-2008, 04:10 PM
Set select problem after form validation - by El Forum - 06-09-2008, 06:02 PM
Set select problem after form validation - by El Forum - 06-09-2008, 06:14 PM
Set select problem after form validation - by El Forum - 06-09-2008, 06:19 PM
Set select problem after form validation - by El Forum - 06-09-2008, 06:22 PM
Set select problem after form validation - by El Forum - 09-01-2008, 01:52 AM
Set select problem after form validation - by El Forum - 09-01-2008, 02:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB