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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:27:23+00:00 2026-06-03T07:27:23+00:00

I need some js/ajax/jquery script saving data to database dynamically when I check the

  • 0

I need some js/ajax/jquery script saving data to database dynamically when I check the check-box.
the checkboxes at the moment or loaded in next to records and change the variable in the database depending if its checked or not.but i have to reload the page after i select one to save it to the database. i can do everything else but understand how to implement the ajax to this so i don’t have to submit the query and refresh the page every time. any help is greatly appreciated.

    <form name="form1aa" method="post" action="process.php?fn=<? echo $rows['first']; ?>&class=<?php echo $rows['class']; ?>&last=<?php echo $rows['last']; ?>
&model=<?php echo $rows['model']; ?>&cas=<?php echo $rows['cases']; ?>&upid=<?php echo $id; ?>&group=1" id="form1a" >

    <select name="type" onchange=" fill_damage (document.form1aa.type.selectedIndex); ">
    <option value="Hardware">Hardware</option>
    <option value="Software">Software</option>
    </select>
    <select name="damage">
    </select>
    <input type=text name="comment"  placeholder="Comments Box">
    <input type=text name="cost"  placeholder="Cost">
    <input type="submit" value="Save" name="Save">
    </form>

<?php

//Job Status
if(isset($_POST['checkbox'])){$checkbox = $_POST['checkbox'];
if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])
$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql="UPDATE repairs SET status = '".(isset($activate)?'Completed':'In Progress')."' WHERE id=$id" ;
$result = mysql_query($sql) or die(mysql_error());
}
//End Job Status

//Payment Status
if(isset($_POST['paycheck'])){$paycheck = $_POST['paycheck'];
if(isset($_POST['paid'])?$paid = $_POST["paid"]:$unpaid = $_POST["unpaid"])
$id = "('" . implode( "','", $paycheck ) . "');" ;
$sql="UPDATE repairs SET paid = '".(isset($paid)?'Paid':'Unpaid')."' WHERE id=$id" ;
$result = mysql_query($sql) or die(mysql_error());
}
//End Payment Status

//Return Status
if(isset($_POST['retcheck'])){$retcheck = $_POST['retcheck'];
if(isset($_POST['ret'])?$ret = $_POST["ret"]:$unret = $_POST["unret"])
$id = "('" . implode( "','", $retcheck ) . "');" ;
$sql="UPDATE repairs SET ret = '".(isset($ret)?'Retuned':'In Office')."' WHERE id=$id" ;
$result = mysql_query($sql) or die(mysql_error());
}
//End Return Status
$sql="SELECT * FROM $tbl_name";
if(isset($_POST['all'])){
    $sql="SELECT * FROM $tbl_name";
}
if(isset($_POST['tpc'])){
    $sql="select * from $tbl_name WHERE class LIKE '1%'";
}
if(isset($_POST['drc'])){
    $sql="select * from $tbl_name WHERE class LIKE 'D%'";
}
if(isset($_POST['bsc'])){
    $sql="select * from $tbl_name WHERE class LIKE 'B%'";
}

$result=mysql_query($sql);

?>
<form  name="frmactive" method="post" action="">
                <input name="activate" type="submit" id="activate" value="Complete Job" />
                <input name="paid" type="submit" id="Payment" value="Payment Status" />
                <input name="ret" type="submit" id="ret" value="Returned 2 Student" />
                <br />

<a id="displayText" href="javascript:toggle();">Show Extra</a>
<div id="toggleText" style="display: none">
<br />
                <input name="unret" type="submit" id="unret" value="In Office" />
                <input name="unpaid" type="submit" id="unpaid" value="Not Paid" />
                <input name="deactivate" type="submit" id="deactivate" value="In Progress" /></div>

<table width="1000" border="0" cellpadding="3" cellspacing="1">
<thead>
<th width="67" align="center"><strong>Start Date</strong></th>
<th width="50" align="center"><strong>Cases</strong></th>
<th width="34" align="center"><strong>Type</strong></th>
<th width="120" align="center"><strong>Damage</strong></th>
<th width="31" align="center"><strong>Comment</strong></th>
<th width="31" align="center"><strong>Cost</strong></th>
<th width="90" align="center"><strong>Payment Status</strong></th>
<th width="100" align="center"><strong>Returned 2 Student</strong></th>
<th width="100" align="center"><strong>Job Status</strong></th>
</thead>

<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>

<td><? echo $rows['start']; ?></td>
<td><? echo $rows['cases']; ?></td>
<td><? echo $rows['type']; ?></td>
<td width="70"><? echo $rows['damage']; ?></td>
<td width="70"><? echo $rows['comment']; ?></td>
<td><? echo "$"; echo $rows['cost']; ?></td>

<!--Payment Display(Start)-->
<?php 
        if($rows['paid']=="Paid")
        {
                ?>
                    <td><input name="paycheck[]" type="checkbox" id="paycheck[]" value="<? echo $rows['id']; ?>">
                <? echo $rows['paid'];?>
                    </td>
                    <?
}

        if($rows['paid']=="Unpaid")
        {
              ?>
                    <td width="21"><input name="paycheck[]" type="checkbox" id="paycheck[]" value="<? echo $rows['id']; ?>">
                <? echo $rows['paid']; ?>
                    </td>
                    <?
}
if($rows['ret']==""){
    ?>
    <td width="50">No Data</td>
    <?
}
?>
  • 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-03T07:27:24+00:00Added an answer on June 3, 2026 at 7:27 am

    Do it with jQuery, a simple example could be:

    HTML:

    <input type="checkbox" name="option1" value="Milk">
    <input type="checkbox" name="option2" value="Sugar">
    <input type="checkbox" name="option3" value="Chocolate">
    

    JS:

    $("input[type='checkbox']").on('click', function(){
       var checked = $(this).attr('checked');
       if(checked){
          var value = $(this).val();
          $.post('file.php', { value:value }, function(data){
              // data = 0 - means that there was an error
              // data = 1 - means that everything is ok
              if(data == 1){
                 // Do something or do nothing :-)
                 alert('Data was saved in db!');
              }
          });
       }
    });
    

    PHP: file.php

    <?php
    if ($_POST && isset($_POST['value'])) {
    
        // db connection
        $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
        if (!$link) {
           // error happened
           print(0);
        }
        mysql_select_db('mydb');
    
        // sanitize the value
        $value = mysql_real_escape_string($_POST['value']);
    
        // start the query
        $sql = "INSERT INTO table (value) VALUES ('$value')";
    
        // check if the query was executed
        if(mysql_query($sql, $link)){
           // everything is Ok, the data was inserted
           print(1);    
        } else {
           // error happened
           print(0);
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to grab some data from the database using JQuery AJAx, and
I need some solution to give relative path in my jquery ajax call as
Possible Duplicate: Jquery:: Ajax powered progress bar? I need to create some kind of
I'm using this jQuery Validation script to submit my form(s), but I need some
i took some interest in this script http://www.9lessons.info/2009/06/comment-system-with-jquery-ajax-and-php.html and i see that the ajax
I am getting some data in JSON format via jQuery and then I need
I need some suggestion on how to work this around. I have an Ajax
I need some help on the JavaScript. I do a ajax call on a
Using RadGrid for Asp.Net Ajax (from Telerik) I need to re-set the CurrentPageIndex. Some
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.