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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:54:36+00:00 2026-06-08T05:54:36+00:00

I made a design with ajax, jquery, mysql and checkbox in php. It is

  • 0

I made a design with ajax, jquery, mysql and checkbox in php. It is like that :

There is box with checkboxes. And there is another box which is empty. When you checked a checkbox in first box, information about that checkbox will be displayed in empty box. I did it and work good.But when you clicked another checkbox, information about first you clicked dissappear and only current selection is displayed. That is to say, I want to add new selection on old ones. Also how can I delete information in second box when I unchecked a checkbox. Thank you.

Here is HTML code :

<div id="first_box"> 
  <label class='checkbox'>
     <input type='checkbox' id=1> 
         First checkbox
  </label>
  <label class='checkbox'>
     <input type='checkbox' id=2> 
         Second checkbox
  </label>
  <label class='checkbox'>
     <input type='checkbox' id=3> 
         Third checkbox
  </label>
</div>
<div id="second_box"> </div>

Here is jquery code :

$(document).ready(function() {

 $("#first_box input:checkbox").change(function() {

    if($(this).is(":checked")) { 

       $.post("/here/is/url", { strID:$(this).attr("id"), strState:"1" },
        function(data) {
         $("#second_box").html(data);
       });

  } else {
      $.ajax({
        url: 'here/is/url/',
        type: 'POST',
        data: { strID:$(this).attr("id"), strState:"0" }
      });
  }
 });    


});  

Here is the php code for ajax request :

$strID    = $_POST['strID'];
$strState = $_POST['strState'];

    if ($strState) { //if checkbox is clicked

        //I fetch data about checkbox which is clicked
        $infos = $this->info_model->get_info_from_checkbox_id($strID);

        foreach ($infos as $info) {
            echo "<label class='checkbox'>
                <input type='checkbox'>".$info->information .
                "</label>"; 
        }
    } else {  // if it is unchecked

         // I do not know how to delete 

    }
  • 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-08T05:54:38+00:00Added an answer on June 8, 2026 at 5:54 am

    I want to add new selection on old ones.

    you can use append() instead of html() which replaces the content:

    $("#second_box").append(data);
    

    how can I delete information in second box when I unchecked a checkbox.

    you can use empty() which removes the contents of the selected element:

    $("#second_box").empty();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So another web bureau made a design for a website that I will code.
I'm building a contact form (PHP file, design has been already made) which will
I am using the GD library with PHP. Basically, I've made a design change
For my app I want to have a design like this example I made
I am reviewing this technology but have a few design concerns that made me
I got some graphic design that was made using JavaScript / Html5 Canvas. Take
I have made a design with a fixed header and footer, with a liquid
Recently i made two template classes,according to the book Modern C++ design. I think
I am trying to understand why this design decision was made with the rename()
More of a design/conceptual question. At work the decision was made to have our

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.