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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:16:08+00:00 2026-06-07T03:16:08+00:00

I am trying to change a drop down based on a previously selected drop

  • 0

I am trying to change a drop down based on a previously selected drop down. I am able to write the function in jQuery.

Since i am not able to use the URL path across various installation based on the server as i have to hard core the URL into the script.

<script type="text/javascript">
function getCategory(){
    var industryId = $("#CompanyCompanyIndustryId").val();
    $.getJSON('http://localhost/gitgrow/users/fetch/'+industryId, function(data) {
        var options = '';
        $.each(data, function(key, value) { 
          options += '<option value="' + key + '">' + value + '</option>';
        });
        $("#CompanyCompanyCategoryId").html(options);
    })
}
</script>

How to achieve the same using CakePHP and JS component ?

  • 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-07T03:16:12+00:00Added an answer on June 7, 2026 at 3:16 am

    You can write your javascript in the page, and use $this->Html->url to build your URL value. Just write it in $this->Html->scriptBlock(); and add 'inline'=>false to make it write in the head instead of at that point of the document:

    $this->Html->scriptBlock("
        function getCategory(){
            var industryId = $(\"#CompanyCompanyIndustryId\").val();
            $.getJSON('" . $this->Html->url(array('controller'=>'users', 'action'=>'fetch', $industryId)) . ", function(data) {
                var options = '';
                $.each(data, function(key, value) { 
                  options += '<option value=\"' + key + '\">' + value + '</option>';
                });
                $(\"#CompanyCompanyCategoryId\").html(options);
            })
        }
    ", array('inline'=>false));
    

    Now you have javascript that’s generated in the <head> (or anywhere else you’d like it to be), and are using CakePHP to build the URL.

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

Sidebar

Related Questions

I'm trying to change the form action based on the selected value from a
I'm trying to make a drop down table using jQuery, with a similar code
So, I'm trying to have same data plotted based on a drop down filter,
I´m trying to change a spring jsp example to use freemarker. I changed all
I am trying to change my many to many script field to use FilteredSelectMultiple
I am trying to change the selected option in a select dropdown box with
I am trying to get a drop down and a form view to work
To piggy back off this post jQuery change the select box value based on
I am trying to get a sql query to run on drop down menu
I'm trying to get a couple spinners to change dynamically based on their previous

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.