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 8010655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:48:16+00:00 2026-06-04T18:48:16+00:00

i’m using code igniter and I made a form with the code igniter form

  • 0

i’m using code igniter and I made a form with the code igniter form helper and I load 2 dropdown boxes with data from my Database and that works perfectly. And when I fill all fields in it works. I have currently 2 required fields. And 1 of them is not required. When I fill in all the required fields, it works, but from when I don’t fill in one required field. It gives this error:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: Cities
Filename: admin/adddivelocation_view.php
Line Number: 67

The code on line number 67 is:

 echo form_dropdown('duikplaats', $Cities, '', $attributes_dropdown_gemeente);

I get the $cities in the view like this:

    function addDiveLocation()
    {
      $data['Cities'] = $this->admin_model->getCity();
      $data['Countries'] = $this->admin_model->getCountries();
      $this->is_logged_in('admin/adddivelocation_view', $data);
    }

My script where the values or the attributes of the 2 drop down menus change are:

         $('#duikplaats').change(function(){
         var data = {
            'id': $(this).val()
         }


        $.get(CI.base_url + "/admin/changeCountry", data, function(content){
            console.log(content);
            $('#duikland option:selected').removeAttr('selected');
            $('#duikland option').filter(function(){
                return $(this).val() == content;
            }).attr('selected', true);
        });

    });

    //Wanneer Land gekozen word
    $('#duikland').change(function(){
        var data = {
            'id': $(this).val()
        }

        $.get(CI.base_url + '/admin/changeCity', data, function(content){
            $('#duikplaats').empty();
            var landen = $.parseJSON(content);
            $.each(landen, function(k, v){
                $('#duikplaats').append(
                    '<option value="' + k + '">'+ v + '</option>'
                    );
            });
        });
    });

and the 2 functies that the jQuery function calls:
changeCountry:

function changeCountry(){

      $query = $this->admin_model->getCountry($this->input->get('id'));

      $this->output->set_output($query->FK_LandID);

    }

changeCity:

function changeCity(){
      $query = $this->admin_model->getCities($this->input->get('id'));

      foreach($query as $object)
      {
        $data[$object->id] =  $object->Gemeente;
      }

      $data = json_encode($data);
      $this->output->set_output($data);
    }
  • 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-06-04T18:48:18+00:00Added an answer on June 4, 2026 at 6:48 pm

    I’ve found the solution. When I post my form it goes trough a validation function, there I load the success view when it is successfully posted or the original view when it failed. When it failed it only loaded the view but I forgot to give any data back to the view so it couldn’t load the data.

    Thanks anyway!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.