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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:01:44+00:00 2026-06-02T21:01:44+00:00

Let’s say I have this form : <form action=Change-status.php method=post> <select class=changeStatus name=changeStatus> <option

  • 0

Let’s say I have this form :

<form action="Change-status.php" method="post">
        <select class="changeStatus" name="changeStatus">
                <option value="0">Starting</option>
                <option value="1">Ongoing</option>
                <option value="2">Over</option>
        </select>
        <input class="projectId" type="hidden" name="projectId" value="<?php echo $data['id'];?>"/>
</form>

I am currently using this script to submit the form, but it implies refreshing :

$('select').change(function ()
{
    $(this).closest('form').submit();
});

What I want to do is to send the form on select change without refreshing the page. I know I have to use AJAX to do so but I couldn’t exactly figure out how to implement it.

Could you orient me on how to do this?

Thanks for your help.

EDIT :

After taking comments into consideration, I ended up with the following code :

Html :

<form action="" method="post">
        <select class="changeStatus" name="changeStatus">
                <option value="0">Starting</option>
                <option value="1">Ongoing</option>
                <option value="2">Over</option>
        </select>
        <input class="projectId" type="hidden" name="projectId" value="<?php echo $data['id'];?>"/>
</form>

JS :

$(document).ready(function() {
    $('select.changeStatus').change(function(){
        $.ajax({
                type: 'POST',
                url: 'Change-status.php',
                data: {selectFieldValue: $('select.changeStatus').val(), projectId: $('input[name$="projectId"]').val()},
                dataType: 'html'
         });
    });
});

PHP :

<?php
    include('../Include/Connect.php');

    $changeStatus=$_POST['selectFieldValue'];
    $id=$_POST['projectId'];

    $sql='UPDATE project SET progress="'.$changeStatus.'" WHERE id="'.$id.'"';

    mysql_query($sql) or die("Erreur: ".mysql_error());
?>
  • 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-02T21:01:46+00:00Added an answer on June 2, 2026 at 9:01 pm

    Getting cross browser onchange events and AJAX requests working isn’t trivial. I’m recommend you use a javascript framework of some kind, which abstracts away all of the cross browser issues so you don’t have to worry about them.

    Try a js framework

    Jquery is just one such framework which has methods such as .change() which attaches a handler to the change event for elements like <select> and .get() which performs a GET request.

    Here’s a little bit of code to get you started:-

    // The $ is the shorthand for a jquery function, you can then use jquery 
    // selectors which are essentially the same as css selectors, so here
    // we select your select field and then bind a function to 
    // it's change event handler
    $('select.changeStatus').change(function(){
    
        // You can access the value of your select field using the .val() method
        alert('Select field value has changed to' + $('select.changeStatus').val());
    
       // You can perform an ajax request using the .ajax() method
       $.ajax({
           type: 'GET',
          url: 'changeStatus.php', // This is the url that will be requested
    
          // This is an object of values that will be passed as GET variables and 
          // available inside changeStatus.php as $_GET['selectFieldValue'] etc...
          data: {selectFieldValue: $('select.changeStatus').val()},
    
          // This is what to do once a successful request has been completed - if 
          // you want to do nothing then simply don't include it. But I suggest you 
          // add something so that your use knows the db has been updated
          success: function(html){ Do something with the response },
          dataType: 'html'
        });
    
    });
    

    Some references that will be better than my explanations

    Please note for this code to work you will need to include the jquery library on you page with a <script> tag.

    See here for a quick start guide on using jquery

    And here for a beginners tutorial on how to use jquery’s ajax() method

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

Sidebar

Related Questions

Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let’s say I have a number like 0x448 . In binary this is 0100
Let's say I have a structure named vertex with a method that adds two
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have a list of objects TheListOfObjects. If I write this: TheListOfObjects
Let's say I have this string which I want to put in a multidimensional
Let's say I have table with column 'URL' whrere I store urls like this

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.