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

  • Home
  • SEARCH
  • 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 3634948
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:50:34+00:00 2026-05-19T00:50:34+00:00

So, basically I have this select / drop down menu that I use AJAX

  • 0

So, basically I have this select / drop down menu that I use AJAX to retrieve and create, though when an option is selected (so onChange) I want it to redirect!

Though, this still isn’t working, I don’t get any errors thrown when trying, and tried to do alert() debug methods yet the alerts don’t get called.

jquery

$("#schoolMenu").change(function() {
  option = $("#schoolMenu option:selected").text();

  alert(option);

  if(option != "- Please Select -") {
   window.location = "http://www.itmustbecollege.com/pics/pics-from-"+$("#schoolMenu option:selected").val(); 
  }
  });

This is what is used to call the AJAX

//
// Populate Schools
//

 $("#state").change(function() {
  option = $("#state option:selected").text();

  if($(this).attr("class") == "menu") {
   if(option != "- Please Select -") {
    $.ajax({
     type: "GET",
     url: "/includes/functions.php",
     data: "f=school&p="+option+"&m=yes",
     success: function(msg) {
      $("#fSchool").html("<p style=\"margin-left: 20px;\">Select School:</p>"+ msg);
      $("#fSchool").show();
      $("#school").focus();
     }
    });
   }
   else {
    $("#fSchool").html("");
    $("#fSchool").hide();
   }
  }
  else {  
   if(option != "- Please Select -") {
    $.ajax({
     type: "GET",
     url: "/includes/functions.php",
     data: "f=school&p="+option,
     success: function(msg) {
      $("#fSchool").html(msg);
      $("#fSchool").show();
      $("#school").focus();
     }
    });
   }
   else {
    $("#fSchool").html("");
    $("#fSchool").hide();
   }
  }
  });

It loads perfectly, if you look at http://www.itmustbecollege.com/quotes/ on that bar where you can do “sort by” of Popular | Newest | Category | School

if you hover over school a dropdown comes up, select any country and another one appears, though when that is changed nothing happens.

here is the PHP for that second drop down

// Get College List
function getCollege($state, $m = "no", $l = "no") {

// Displays Schools
if($m == "yes") {
 $options = '<select id="schoolMenu" name="school"><option value="select" selected="selected">- Please Select -</option>';
}
else if($l == "yes" || $l == "yes2") {
 $options = '';
}
else {
 $options = '<select name="school"><option value="select" selected="selected">- Please Select -</option>';
}

$listArray = split("\|\\\\", $list);

for($i=0; $i < count($listArray); $i++) {

 if($m == "yes") {
  $options .= '<option value="'. trim(titleReplace($listArray[$i])) .'">'. trim($listArray[$i]) .'</option>';
 }
 else if($l == "yes") {
  $options .= '<li><a href="/quotes/quotes-from-'. titleReplace($listArray[$i]) .'" title="'. trim($listArray[$i]) .' Quotes">'. trim($listArray[$i]) .'</a></li>';

 }
 else if($l == "yes2") {
  $options .= '<li><a href="/pics/pics-from-'. titleReplace($listArray[$i]) .'" title="'. trim($listArray[$i]) .' Pictures">'. trim($listArray[$i]) .'</a></li>';

 }
 else {
  $options .= '<option value="'. trim($listArray[$i]) .'">'. trim($listArray[$i]) .'</option>';
 }
}

echo $options .='</select>';
return false;
}

any help would be great!

EDIT: Also, the way I have those drop downs coming for the menus is a bit weird and when you hover over any other “sort by” link they disappear, this is a problem with the “sort by school” because the first select box shows the list up, and if you go and select a school then somehow float over another link it disappears, any help on how to delay that or fix that minor problem?

  • 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-19T00:50:34+00:00Added an answer on May 19, 2026 at 12:50 am

    It is because the #schoolMenu element isn’t present when the page loads, so you .change() handler doesn’t get assigned.

    You can assign it when it arrives.

    var fSchool = $("#fSchool").html("<p style=\"margin-left: 20px;\">Select School:</p>"+ msg);
    
    fSchool.find("#schoolMenu").change(function() {
      option = $(this).find("option:selected").text();
    
      alert(option);
    
      if(option != "- Please Select -") {
         window.location = "http://www.itmustbecollege.com/pics/pics-from-"+$("#schoolMenu option:selected").val(); 
      }
    });
    
    fSchool.show();
    

    Note that I cached $("#fSchool") in the fSchool variable, instead of repeatedly selecting it from the DOM.

    And inside the .change() handler, I reference the element that received the event using this instead of "#schoolMenu", again to avoid repeated DOM selection.

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

Sidebar

Related Questions

I'm trying to create a select box drop down with a twist, Basically this
Well basically I have this script that takes a long time to execute and
Basically you have two ways for doing this: for (int x = 0; x
I'm not really sure how to title this question but basically I have an
I have an ASP.NET application. Basically the delivery process is this one : Nant
I have written a secure TCP server in .NET. This was basically as simple
this kind of follows on from another question of mine. Basically, once I have
ok so I am trying to dynamically create a select list using javascript, basically
I basically have a page which shows a processing screen which has been flushed
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp

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.