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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:29:10+00:00 2026-06-08T21:29:10+00:00

I am new in jquery . I don’t know why this code is not

  • 0

I am new in jquery . I don’t know why this code is not working . I have 3 dropdown box. Depending on f_cat1 and f_cat2 , f_university_name will be fetched , as f_cat1 and f_cat2 can’t be empty that’s why i am checking if f_university_name is empty , trying to gathering data in it . or f_cat1 or f_cat2 is changed , also trying to do this operation.

Would you anyone please help me? Here is my code:

$(document).ready(function(){

     var cat1= $('#f_cat1').val();    // f_cat1,f_cat2 is the id of a dropdown box 
     var cat2= $('#f_cat2').val();

     $('#f_cat1').change(make_change);
     $('#f_cat2').change(make_change);

     var uni_name= $('#f_university_name').val();  
     if(uni_name=="")
     {
         make_change();
     }

});

function make_change()
{
    var post_url ="<?php echo $c_link.'get_university/';?>"+ cat1+'/'+cat2;
    //  alert(post_url);
    $.ajax({
        type: "POST",
        url: post_url,
        //  dataType : "JSON",
        success: function(unis) 
        {
           //  alert('hi');
           $('#f_university_name').empty();
           $.each(unis,function(university_id,university_name)
           {
              var opt = $('<option/>'); 
              opt.val(university_id);
              opt.text(university_name);

              $('#f_university_name').append(opt);
           });


     } //end success
  }); //end AJAX
}

After edit1 : Thanks to all for replying me , it has started to work . But the problem is i am unable to comment my reputation is low . I am new to stack overflow , i didn’t know about rules . And i am unable to click anything…. how could i get rid of this?

  • 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-08T21:29:11+00:00Added an answer on June 8, 2026 at 9:29 pm

    There are no varianbles cat_1 and cat_2 in your function make_change, because they are local in $(document).ready(function () { ... });. Move the defenition of make_change function into $(document).ready(function () { ... }); block, then you’ll have access to them.

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

Sidebar

Related Questions

I'm new to jquery and I kinda don't get around this. So I have
I am new to jQuery and so don't mind this question if it sounds
I'm rather new to jQuery, so I really don't know if the following problem
im new to jquery and javascript.. Here is the code, this is a sample,
I'm new to JQuery and don't have a huge background in Javascript, either -
im very new to jquery/javascript. So here goes, I found this js code for
I'm very new to JQuery and don't have much experience with javascript at all,
I'm using Jquery(don't know if that's relevant), here's the regex: var re = new
I am new Jquery and have written a toggle function that looks like this:
I'm new to jQuery and just playing for fun. I have some code that

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.