• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dynamic form dropdown

#1
[eluser]jonyork[/eluser]
I need a bit of help.

Im trying to create a form with dynamic dropdowns.

here is my view

Code:
<h1>Update Member</h1>

&lt;?php echo form_open('membership/update');

    echo form_input('ID', set_value('ID', 'ID'));

    echo form_input('Last_Name', set_value('Last_Name', $query['Last_Name']));

    echo form_input('First_Name', set_value('First_Name', $query['First_Name']));

    echo form_input('Salutation', set_value('Salutation', $query['Salutation']));

    echo form_input('Address', set_value('Address', $query['Address']));
    
    echo form_input('City', set_value('City', $query['City']));
    
    echo form_input('Postal', set_value('Postal', $query['Postal']));
    
    echo form_input('Phone_1', set_value('Phone_1', $query['Phone_1']));
    
    echo form_input('Phone_2', set_value('Phone_2', $query['Phone_2']));
    
    echo form_input('Language', set_value('Language', $query['Language']));
    
    echo form_input('Membership_Cat', set_value('Membership_Cat', $query['Membership_Cat']));
    
    echo form_input('Special_Member_Cat', set_value('Special_Member_Cat', $query['Special_Member_Cat']));
    
    echo form_input('Membership_Status', set_value('Membership_Status', $query['Membership_Status']));

    echo form_submit('submit', 'Update Member');

    echo form_close();
    
?&gt;

while it does retrieve the information from the database, a few of them are dropdowns in the "add member" and I would like to have those dropdowns in the update fields, and have the proper value selected in the dropdown.

any help is very appreciated

#2
[eluser]jonyork[/eluser]
I managed to simplify things, but im still not getting it to work properly

Code:
&lt;?php
    
    $salutation = array(
        'Mr.' => 'Mr.',
        'Mrs.' => 'Mrs.',
        'Dr.' => 'Dr.',
        );    
    
    echo form_open('membership/update');

    echo form_dropdown('Salutation', $salutation, 'Mrs.');

?&gt;

The dropdown is posting the value to the database, so that is good, however, the third option 'Mrs.' is not selected by default.

How can I get that to work?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.