Unable to retrieve the value of the dependent dropdown from the region dropdown

I am looking to display the geozone in the registration process as a dropdown menu, similar to the zone (region) selection. However, the options available for the geozone should be dynamically updated based on the zone selected by the customer.

The Visual Representation

To achieve this, I have made certain modifications to the controller and view files. The screenshot below illustrates the current state:

The geozone field is currently displaying Kotamadya/Kabupaten. However, when I choose the region Aceh, the geozone field does not update accordingly.

Error Message Encountered

An error message was displayed as follows:

SyntaxError: Unexpected token <

OK

<br />
<b>Fatal error</b>: Call to a member function
getGeozonesByZoneId() on a non-object in <b>
/home/........../catalog/controller/account/register.php
</b> on line <b>513</b><br />

The Code Snippet

In ../controller/account/register.php, I made the following adjustments:

public function zone() {
    $json = array();
    
    // Code block referencing model_localisation_zone
    
    if($geozone_info)
    {
        // Code block referencing model_localisation_geo_zone
        
        $json = array(
            // JSON object properties
        );
    }
    $this->response->setOutput(json_encode($json));
}

The specific line causing the issue is mentioned as:

'geozone'           => $this->model_localisation_geozone->getGeozonesByZoneId($this->request->get['zone_id'])

I believe the getGeozonesByZoneId function is implemented correctly in ../model/localisation/geo_zone.php as shown below:

    <?php
// PHP code snippet of ModelLocalisationGeozone class
?>

Additionally, JavaScript code has been included in register.tpl for handling the dynamic updates:

// JavaScript code snippet

If anyone has insights or solutions to help me resolve this issue, your assistance would be greatly appreciated. Thank you in advance!

Answer №1

It is recommended to utilize the variable model_localisation_zone instead of using model_localisation_geozone, which is currently not defined. Alternatively, ensure that the latter variable is properly defined.

Answer №2

It seems like you may have overlooked loading the Geozone model in your register.php controller file. Make sure to include this line:

$this->load->model('localisation/geozone');

within the register.php file, before calling the function:

$this->model_localisation_geozone->getGeozonesByZoneId($this->request->get['zone_id'])

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Application: The initialization event in the electron app is not being triggered

I am facing an issue while trying to run my electron app with TypeScript and webpack. I have a main.ts file along with the compiled main.js file. To troubleshoot, I made some edits to the main.js file to verify if the "ready" function is being called. ...

Error: The module '/@modules/vue.js' does not export a 'default' value as requested by the syntax

I'm encountering an issue with Vee Validate form validation in Vue.js. As a beginner, I am struggling to grasp the import syntax. After installing vee-validate using npm i vee-validate --save and placing it in my node_modules directory, I proceeded to ...

Use Google script to input drop down options directly into a Google spreadsheet

After gathering coding advice from various StackOverflow examples, I've hit a roadblock while attempting to take my script to the next level. The task seems simple enough, but for some reason, I just can't figure it out. Here's the situati ...

Tips for automatically refreshing a token with Auth0 on Nuxt without interrupting the user experience

Currently, the platform I'm working on has decided to outsource authentication to a service called Auth0. We were able to successfully set up the login and logout flows by redirecting users to a hosted Auth0 page and then back to our platform after a ...

React/JS property divided by a colon

Can you explain the significance of the colons used in between { placeholder }: { placeholder: string } within the props of the Search component? This pattern is also seen later in the code for the main Page component.... Does it signify that the expected ...

Tips for achieving a standard dropdown appearance in a collapsed navbar with Bootstrap split button dropdown

Trying to create a navbar with a split dropdown button has been a challenge. The design either goes awry when the screen is narrow and the navbar is hidden behind the toggle, or it doesn't look right on a wider screen when the navbar is expanded. Cur ...

Steps for eliminating empty values from the JSON data

How can I eliminate the properties that have null values in the following input data? var data = [ { "Id": "parent", "Function": "Project Management", "Phase": "(Null)" }, { "Id": "1", "Function": "R&D Team", "Phase": "parent" }, ...

What is the best way to pass a variable into a function within an HTML tag function in JavaScript?

I am currently developing an HTML web application that retrieves data from API calls, stores it in an array, and then uses the map function in JavaScript to display the data. Here is a sample of my data set: contDet = [ { idappcontent: "Review1_ ...

various issues with fonts and Uncaught Eval error

I've been encountering multiple font/style errors and an uncaught eval. I have attached a picture for reference. My Angular application is not functioning properly, and I suspect these errors may be the reason. However, I am unsure of their significan ...

Efficient JSON management for requests and responses in Grails

I pondered whether there is a universal method to parse requests in a standardized manner or append fields to a JSON response for every transmission. It would be ideal for me to handle and interpret something like this: { transactionId:456, // includ ...

How to use jQuery to delete specific table rows while keeping the first row safe from removal

Currently, I have a jQuery script that successfully removes table rows when a button is clicked. However, I want to prevent the button from removing the first row of the table. Is there a way to achieve this? $("#remove").click(function(event) { ...

Maintaining the sequence of a PHP associative array when transferring it to JavaScript via ajax

Below is the code from my PHP file: GetUserArray.php $Users = array('7'=>'samei', '4'=>"chaya", '10'=>'abetterchutia'); echo json_encode($Users); Here is the AJAX request I am using: $.ajax({ ...

Tips for integrating JavaScript libraries with TypeScript

I'm looking to add the 'react-keydown' module to my project, but I'm having trouble finding typings for it. Can someone guide me on how to integrate this module into my TypeScript project? ...

Navigate through chosen options by clicking on a button

It's a new day and I'm facing a simple challenge that seems complicated in the morning haze. I need to create a select dropdown with zoom percentage values, along with + and - buttons to navigate through the list. If I have the following setup: ...

Issue encountered during Node.js installation

Every time I attempt to install node js, I encounter the following errors: C:\Users\Administrator>cd C:/xampp/htdocs/chat C:\xampp\htdocs\chat>npm install npm WARN package.json <a href="/cdn-cgi/l/email-protection" class ...

Selecting a date in Jade's date picker

I'm currently facing an issue with getting a datepicker to function properly using Jade in a node.js and express framework. Within index.jade, I am loading the necessary javascript files like this: link(type='text/css', href='css/ui-l ...

Exploring ways to extract nested JSON object values and categorize them according to a set condition within Jmeter

Response: { "rid": 2016, "userid": "abcd", "cid": "xyz", "rname": "ijk", "des": null, "con": [{ "fname": "amnt_type", "op": "eqto", "vtype": "ENUM", "values": [{"v1": "I", "v2": null}] }, { "fname": "usd", "op": "GT", "vtype": "NUMERIC", "values": [{"v1 ...

What could be causing the images to not display on my HTML page?

My program is designed to display an image based on the result of the random function. Here is my HTML: <div> <h2>Player 0:</h2> <div id="MainPlayer0"></div> </div> Next, in my TypeScript fi ...

What is the best way to keep the rotateblock within the designated section boundaries?

Issue: The blue block is getting out of the section due to the transform property set as rotate. How can this be resolved? https://i.sstatic.net/F0exR.png section { padding: 10px 0 40px; background: #ececec; height: 1600px; } .filter { display ...

Is it possible to use Javascript to query the neo4j database?

After creating a geohash neo4j database for NYC Taxi data, the next step is to visualize it on a map. I decided to use Leaflet as a JavaScript library. Using static data, I was able to plot geohash data in Leaflet: https://i.sstatic.net/AtQKZ.jpg Now, my ...