Welcome Guest, Not a member yet? Register   Sign In
Code does not seem to work?
#1

[eluser]Tom Glover[/eluser]
I have a clients website, in which I need it to write a form from and array.

In the view file:
Code:
<select name="relayletter2" id="relayletter">
            &lt;? if (is_array($letters)){
                  foreach ($letters as $letter)
                 {
                     if($letter === $selected)
                        {?&gt;
                        <option selected="selected" value="&lt;?=$letter?&gt;">&lt;?=$letter?&gt;</option>
                      &lt;?  }else{ ?&gt;
                           <option value="&lt;?=$letter?&gt;">&lt;?=$letter?&gt;</option>
                   &lt;?  }
                    }
                }?&gt;        
              </select>

The array that is passed to it:
Code:
$letters = array('a','b','c','d','e','...')

It is meant to compare that to what it is getting for the database, and when it finds a match it is meant to set the option selected.

At the Moment all options are selected.


Messages In This Thread
Code does not seem to work? - by El Forum - 04-10-2008, 06:49 AM
Code does not seem to work? - by El Forum - 04-10-2008, 07:16 AM
Code does not seem to work? - by El Forum - 04-10-2008, 08:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB