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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:52:19+00:00 2026-05-17T16:52:19+00:00

I’m setting up dynamic pulldowns: the choice on select#category informs the contents of select#subcat.

  • 0

I’m setting up dynamic pulldowns: the choice on select#category informs the contents of select#subcat.

this is the html for select#category:

<select name="category" id="category">
    <option>Click Here to choose a category</option>
           <?php foreach ($categories as $key => $category) { ?>
    <option value="<?php echo $key ?>"><?php echo $category ?></option>
           <?php } ?>         
</select>

<select name="subcat" id="subcat">
    <option>&lt;-- First Choose a Category</option>                           
</select>

this is the jQuery statement:

$(document).ready(function(){
    $("select#category").change(function(){
        $("select#subcat").load("subcats.php",{ id: $(this).val(), ajax: 'true'});
    });
});

this is subcats.php:

<?php
      //source of categories
      include("config.php") ;
      //initiate option list
      $options =  '<option value="">Choose a Sub-category</option>'."\n" ;
      if(!empty($_GET["id"])) {
      //iterate through the categories
      foreach ($categories as $key => $category) {
      if ($_GET["id"] == $key) {
      //select the data source
      $subcats = file('subcat/'.$key.'.dat', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ;
      natsort($subcats);
      //create the rest of the option list
          foreach ($subcats as $subcat) {
          list ($subname,$subkey ) =explode ("\t", $subcat) ;
           $options .=  '<option value="'.$subkey.'">'.$subname.'</option>'."\n" ;
      }
      echo  $options ;   
          }
      }
      }  else {
      // if no variable given provide option list as error check
      echo  '<option value="">&lt;-- Choose a Category First</option>
      <option value="">Foo Bar</option>'."\n" ;   
          }
      ?>

My understanding is that id: $(this).val() provides the selected option from select#category for use in the php document; am I off base here? Really, if I’m reading the docs right, I shouldn’t even need the , { id: $(this).val(), ajax: 'true'} bit
the ajax request .load is working, because the error check menu items appear in the select#subcats.

However, that’s all that appears: the variable does not seem to be getting through…

Li’l help here? Thanks in advance!

  • 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-17T16:52:20+00:00Added an answer on May 17, 2026 at 4:52 pm

    use console.log($(this).val()) before .load to debug the submitted value

    are you sure the data is send per get method?

    Example: Same as above, but will POST
    the additional parameters to the
    server and a callback that is executed
    when the server is finished
    responding.

    $("#feeds").load("feeds.php", {limit:
    25}, function(){ alert("The last 25
    entries in the feed have been
    loaded"); });

    and as found under the comments on http://api.jquery.com/load/

    According to the documentation: “The
    POST method is used if data is
    provided as an object; otherwise, GET
    is assumed.”

    You could simply use $_REQUEST['id'] instead of $_GET['id'] or $_POST['id'] to cover both (see php.net::$_REQUEST for more informations)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group

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.