Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:34:40+00:00 2026-05-23T13:34:40+00:00

I am trying to populate my dynamic dropdown menu using CI: My issue is

  • 0

I am trying to populate my dynamic dropdown menu using CI:

My issue is that when I set my dropdown value and text ($formImageCaptionDropDown = array($get_images['id'] => $get_images['description']);) it does not display – just displays a blank dropdown box.

I have done print_r on my $get_images so I know that this is working correct.

I also know that I am to use $var['value'] because I have copied the format of another page that uses the images model and is working fine.

I just cannot seem to populate the dropdown menu

I have the following code:

<?php
//Setting form attributes
$get_images = $this->image_model->getImages();
$formImageCaption = array('id' => 'imageCaption', 'name' => 'imageCaption');
$formImageCaptionDropDown = array($get_images['id'] => $get_images['description']);
$formImageCaptionSelection = array('id' => 'captionSelection', 'name' => 'captionSelection');
$formSubmit = array('id' => 'submit','name' => 'submit','value' => 'Edit Caption');
?>
<div id ="formLayout">
<?php echo form_open('admin/imagecaption',$formImageCaption);
  echo form_fieldset(); 
?>
<p>Please Select A Caption Below To Edit: </p>

<?php echo form_label ('Caption:', 'caption');?>
<?php echo form_dropdown('caption', $formImageCaptionDropDown); ?>

<div id="errorCaption"><?php echo form_error('caption');?></div>
<span class="small">Required Field</span>

    <?php echo form_fieldset_close();
  echo form_close(); ?>
   </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:34:41+00:00Added an answer on May 23, 2026 at 1:34 pm

    I have resolved my issue by doing the following:

    1. I moved the line $get_images = $this->image_model->getImages(); into my controller as $data['$get_images'] = $this->image_model->getImages();

    2. In my view I did the following:

    <?php foreach ($get_images as $image){
        echo '<option value="'.$image['id'].'">'.$image['description'].'</option>';
    };
    ?>`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to populate a string with a double value using a sprintf
I'm trying to load some XML into flash to populate some dynamic text fields.
I'm trying to populate a second dropdown in a dynamic way based on a
I am trying to populate an HTML select list using an array of customer
When running a Dynamic array that is populated I am trying to get the
I am trying to populate an asp:Menu control using an XML file. I want
I'm trying to populate a DataTable, to build a LocalReport, using the following: MySqlCommand
So I am trying to have a dynamic tabs kind of thing using both
I am trying to populate an excel spreadsheet using VBA (is actually something different
I am trying to populate a row in a table given a key value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.