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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:00:39+00:00 2026-06-17T12:00:39+00:00

I want to create an auto refresh table whenever I submitted the form below

  • 0

I want to create an auto refresh table whenever I submitted the form below using jQuery Ajax.

Here is my form

<form id="submitDataToElection">
  <table border="0">
  <tr>
    <td><label for="electionName">Election Name:</label></td>
    <td><input type="text" name="electionName" id="electionName" spellcheck="true" required></td>
  </tr>
  <tr>
    <td><label for="electionDate">Election Date:</label></td>
    <td><input type="text" name="electionDate" id="electionDate" required></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="Reset" type="reset" value="Reset" id="resetInAddElection"><input type="submit" value="Submit" id="submitInAddElection"></td>
  </tr>
  </table>
</form>

The Form’s jQuery

$("#submitDataToElection").submit(function(event) {
    $("#resetInAddElection, #submitInAddElection").attr("disabled",true);
    event.preventDefault();
    var values = $(this).serialize();
    $.ajax({
      url: "storeDataToElection.php",
      type: "post",
      data: values,
      success: function(data){
          $('#addElection').dialog('close');              alert(data);
          $("#resetInAddElection, #submitInAddElection").attr("disabled",false);
          $("#electionName,#electionDate").val("");
          $("#electionName").focus();
      },
      error:function(data){
          $("#resetInAddElection, #submitInAddElection").attr("disabled",false);
          alert("failure");
      }   
    }); 
});

here is the code for storeDataToElection.php

mysql_connect("localhost", "root", "");
mysql_select_db("automated_election");
$name = $_POST['electionName'];
$date = $_POST['electionDate'];

mysql_query("UPDATE election SET is_active = 'no' WHERE is_active = 'yes'")or die(mysql_error());
$insert = mysql_query("INSERT INTO election
    (election_name ,
    election_date ,
    is_active)
    VALUES('$name', '$date', 'yes')");
if(!$insert) die(mysql_error());
else die("Success");

Here is the table I want to auto-refresh

$result = mysql_query("SELECT * FROM election WHERE is_active = 'yes'");
echo '<hr><table style="font-size:14px;" id="viewElectionTable">';
while ($data = mysql_fetch_assoc($result)) {
    $date = explode("-",$data['election_date']);
    switch($date[1]){
        case 1:
            $month = "January";
            break;
        case 2:
            $month = "February";
            break;
        case 3:
            $month = "March";
            break;
        case 4:
            $month = "April";
            break;
        case 5:
            $month = "May";
            break;
        case 6:
            $month = "June";
            break;
        case 7:
            $month = "July";
            break;
        case 8:
            $month = "August";
            break;
        case 9:
            $month = "September";
            break;
        case 10:
            $month = "October";
            break;
        case 11:
            $month = "November";
            break;
        case 12:
            $month = "December";
            break;
    }
    echo '<tr>';
    echo "<td>Election Name: &nbsp;&nbsp;</td><td>".$data['election_name'].'</td>';
    echo '</tr><tr>';   
    echo "<td>Election Date: &nbsp;</td><td>".$month." ".$date[2].", ".$date[0].'</td>';
    echo '</tr>'; 
}
echo '</table><hr>';
  • 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-17T12:00:40+00:00Added an answer on June 17, 2026 at 12:00 pm

    The general idea is to use the file your ajax hits to output the new table HTML.
    Then use the HTML output returned to your ajax call to replace the existing table on your page.

    For example:

    Put the table you want to refresh inside a div and give that div an id to reference.
    In my example below, I’m using

    <div id="tableHolder"><!-- TABLE GOES HERE --></div>
    

    In storeDataToElection.php, after you write to your database, output your new table HTML. This HTML output will be returned to your ajax call’s “success” function.

    Then, you can replace the table with the new content by doing something like this:

    success : function(updatedTable) {
      ...
      $('div#tableHolder').html(updatedTable);
      ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new to smartGWT . i want to create auto login using j_security_check
I want to create a convention for column names using Fluent NHibernate auto mapping.
I want to create a primary key(auto-increment) which is start with A001000001 . Here
I want to create an auto complete program and I am using JComboBox for
I want to add an image inside a div(#bg) using jquery to create an
I want to create a table that can auto calculate some values for each
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want to create a new field (or two) in my table that is
I want to create auto-hide menu, just the same thing like http://www.ringvemedia.com/shanghai-photos but the
I want to create a auto-suggest text box which would query the database at

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.