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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:20:59+00:00 2026-06-05T15:20:59+00:00

Below is my form. Using jQuery I load a <select> element based on value

  • 0

Below is my form.
Using jQuery I load a <select> element based on value on previous <select>. However when I send the form the value of the dynamically added <select> (add_student_contact_id) is not beeing $_POST‘ed. Is it because it’s beeing added after the page load? Is there any way to solve it?

students.php

    <form action='../insert.php' method='post' name='add_student'>

    <!-- This is generated by PHP -->

    <select id='add_student_customer'>
        <option>Select one...</option>
        <option value='1'>First value</option>
        <option value='2'>Second value</option>
        <option value='3'>Third value</option>
    </select>

    <!-- Here a select element will load from another PHP-file based on values from the previous select -->
    <div id='add_student_contactperson_container'></div>

    <!-- This is generated on page load but will not be visible until we select something in the previous select -->
    <select id='add_student_course'>
      <option>Select something...</option>
      <option value='1'>An option</option>
      <option value='2'>A second option</option>
    </select>
    </form>

jQuery

<script>
$(document).ready(function() {
$("#add_student_course_container").hide();
$(document).on("change", "#add_student_customer_select", function(){
        var row_id = $(this).val();
        $.ajax({
            url: "/load_customer_contacts.php",
            data: { 'customer_id':row_id },
            success: function(data){
                $("#add_student_contactperson_container").html(data);
            }
        });
    });
});
$(document).on("change", "#add_student_contact", function(){
   $("#add_student_course_container").show();
});
</script>

/load_customer_contacts.php

if (isset($_GET['customer_id'])) {

/* SQL stuff */

echo "<select name='add_student_contact_id'>\n";
    while ($row = mysql_fetch_assoc($sql)) {
        echo "<option value='".$row['contact_id']."'>".$row['name']."</option>\n";
    }
echo "</select>\n";
}
  • 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-05T15:21:00+00:00Added an answer on June 5, 2026 at 3:21 pm

    One possible reason is that $row['contact_id'] doesn’t have a value when injected into the page. Another reason is you are missing a name attribute. This would mean the browser is either:

    • Sending the blank value
    • Omitting it completely

    If you could check that and post back we could provide some more help.

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

Sidebar

Related Questions

My form has a custom element like below, created using custom ajax: <select jwcid=testtest
I have a form to 'create a tag'. Using the jQuery code below. $(#createtag).submit(function()
Using jQuery/jQueryUI I want to populate a form using this HTML/JS show below. The
Having a problem with dynamically populated select boxes using jQuery. Basically, my code calls
How do I properly load the a certain value into a textbox using jQuery?
I have added the client side validations on a form using jQuery's validate() function
in my form load i download a image using jquery and when user click
Using jquery alerts dialog plugin , how do I send a value in a
I am using jquery.form.js (version: 2.84) and in the below code, I see that
I am using JQUERY .ajax() to send serialized form data to MySQL using PHP.

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.