Welcome Guest, Not a member yet? Register   Sign In
drop down list ?
#1

[eluser]buckboru[/eluser]
I am loading a dropdown list. I can successfully load the list on a entry screen.
My question is on an update view. How do i make the drop down list to the previously entered value from a data base record.

FOr example
<td valign="top">System<span style="color:red;">*</span></td>
<td><select name="SYSTEM" size 5/>
<option value ="RG" selected>RG</option>
<option value ="RGT">RGT</option>
<option value ="NET">NET</option>
<option value ="EXCH">EXCH</option>
<option value ="RCRD">RCRD</option>
</select>


RG is the Default. But suppose the record i'm updating has the value 'NET' How would i make the selected value be 'NET'?
#2

[eluser]Johan André[/eluser]
use the form_dropdown()-function in the form-helper.

or

use the set_select()-function which is also in the form-helper...

Good luck!
#3

[eluser]slowgary[/eluser]
The form helper does this for you. http://ellislab.com/codeigniter/user-gui...elper.html
#4

[eluser]buckboru[/eluser]
OK, i'm making progress now. However, its still not working and i'm not sure why.
In the code below, when i run through debug on an 'Update', $selopt shows a value of 'RGT' for the specific record when the echo form_dropdown is executed.
However when the page is displayed, it shows a value of 'RG'
I cannot figure out what is going on. Any ideas?
THanks for any help you can provide.

Code:
<td>&lt;? echo 'System'.'&nbsp;&nbsp;';?&gt;</td>
&lt;? $options = array(
              'RG' => 'RG',
              'RGT' => 'RGT',
              'NET' => 'NET',
              'EXCHG' => 'EXCHG')  ; ?&gt;  
&lt;? if ($method == 'ADD')
    {  
    $selopt = 'RG';
    }
    else
    {
       $selopt = $this->validation->SYSTEM ;
    }    
?&gt;      
<td>&lt;? echo form_dropdown('system',$options,$selopt); ?&gt;
    &lt;? echo $this->validation->SYSTEM_error; ?&gt;</td>




Theme © iAndrew 2016 - Forum software by © MyBB