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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:41:15+00:00 2026-06-08T07:41:15+00:00

I am using a JS/Ajax function to echo Selected values from select boxes. I

  • 0

I am using a JS/Ajax function to echo Selected values from select boxes. I am populating these select boxes with values from MySQL DB. The function works with text input fields but now that I am using it with these select boxes I am getting no response.

Can I echo the selected value from a select box with the JS? or Is there a better way? EXAMPLE

JS

 <script>
    $(document).ready(function() { 
        var timer = null;  
        var dataString;    
        function submitForm(){ 
            $.ajax({ type: "POST", 
                url: "index.php", 
                dataType: 'json', 
                success: function(result){ 
                $('#special').html('<p>' +  $('#resultval', result).html() + '</p>');} 
                                  }); 
            return false; 
        } 
        $('#category_form').on('change', function() { 
            clearTimeout(timer); 
            timer = setTimeout(submitForm, 2000); 
        }); 
    });  
    </script>

PHP/HTML

try {

    $pdo = get_database_connection();   

    $sql = "SELECT * 
            FROM `categories`
            WHERE `master_id` = 0";
    $statement = $pdo->query($sql);
    $list = $statement->fetchAll(PDO::FETCH_ASSOC);


} catch(PDOException $e) {
    echo 'There was a problem';
} 

    <form action="" method="post" id="category_form'" name="category_form'">

            <select name="main" id="main" size="7" class="update">
                <option value="">Select one</option>
                <?php if (!empty($list)) { ?>
                    <?php foreach($list as $row) { ?>
                        <option value="<?php echo $row['id']; ?>">
                            <?php echo $row['name']; ?>
                        </option>
                    <?php } ?>
                <?php } ?>
            </select>

            <select name="subc1" id="subc1" size="7" class="update"
                disabled="disabled" hidden="hidden">
                <option value="">----</option>
            </select>

            <select name="subc2" id="subc2" size="7" class="update"
                disabled="disabled" hidden="hidden">
                <option value="">----</option>
            </select>

            <select name="subc3" id="subc3" size="7" class="update"
                disabled="disabled" hidden="hidden">
                <option value="">----</option>
            </select>

        </form>

    <div id="special"></div>
  • 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-08T07:41:16+00:00Added an answer on June 8, 2026 at 7:41 am

    It looks like you’re selecting the wrong element with jQuery.

    Change:

    $('#category_form').on('change', function() { 
                clearTimeout(timer); 
                timer = setTimeout(submitForm, 2000); 
            }); 
    

    To:

    $('#main').on('change', function() { 
                clearTimeout(timer); 
                timer = setTimeout(submitForm, 2000); 
            }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My table is being populated using ajax from a mysql database. I have a
I obtained the data from the server using ajax like this: (EDITED) $(document).ready(function() {
I am using jQuery and ajax function to access a php file that echo
I am using ajax to get data from a php file function getdata(param) {
I am making a function so that I can post from Ajax using a
I am using the ajax() function to send a string to a PHP file.
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I'm using the JQuery AJAX function to deliver data to a PHP doc. Currently,
I am calling a php function using ajax call but its not working. I
Here is the code I'm currently using: $.ajax({ success: function(){ $('.post_container').append('test <br />'); }

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.