Welcome Guest, Not a member yet? Register   Sign In
need help with set_select
#1

[eluser]Skuja[/eluser]
Hi, the following code:
Code:
<select name="sim_id">
        <option value=""></option>
        &lt;?    
        foreach($sim_query->result() as $sim)
        {
        echo '
          <option value="'.$sim->id.'" '. (isset($this->validation->sim_id))?$this->validation->set_select('sim_id',$sim->id):($sim->id == $row->sim_id)?'selected="selected"':'' .' >'.$sim->id.'</option>';
        }
        ?&gt;
        </select>
produces following html:
Code:
<select name="sim_id">
        <option value=""></option>
         >7</option>

           >3</option>
           >5</option>
           >6</option>
                  </select>

any ideas why it doesn't create opening option tags?
#2

[eluser]Pascal Kriete[/eluser]
Wow, would it kill you to have that on more than one line?

I'm pretty sure it's that mess of a conditional statement, but I can't figure out what in the world it's supposed to do. It's not something that looks appealing on a monday morning. Any chance you could split that up?
#3

[eluser]Skuja[/eluser]
you were right - there was too many of those ternaries.. Smile
when I rewrited to this:
Code:
<option value=""></option>
        &lt;?    
        foreach($sim_query->result() as $sim)
        {        
            echo '<option value="'.$sim->id.'" ';
            if(isset($this->validation->sim_id))
            {
                echo $this->validation->set_select('sim_id',$sim->id);
            }
            elseif($sim->id == $row->sim_id)
            {
                echo 'selected="selected"';
            }
              echo '>'.$sim->id.'</option>';
        }
        ?&gt;
        </select>
it produced right html..




Theme © iAndrew 2016 - Forum software by © MyBB