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

  • Home
  • SEARCH
  • 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 7047161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:44:15+00:00 2026-05-28T02:44:15+00:00

I have this JQuery code: jQuery(#form).click(function() { $(input[name=’copyno’]:checked).each(function() { checkboxData = copyno=+$(this).val(); id=$(this).val(); jQuery.ajax({

  • 0

I have this JQuery code:

jQuery("#form").click(function() {

$("input[name='copyno']:checked").each(function() {

    checkboxData = "copyno="+$(this).val();

id=$(this).val();

   jQuery.ajax({
      url: "renewall.php",
      type: "POST",
      data: checkboxData,
      cache: false,
      dataType: "text",
      success: function(data) {

    $("#" +id).html(data);             

    }
});
});
});

What I’am trying to do is to put the response data into specific divs based on checkboxes values, in this case the id, but the response data only shows in the same div id (
id=$(this).val();) instead of to be shown there where it has the same id value.

Som Kind og iteration problem

  • 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-05-28T02:44:16+00:00Added an answer on May 28, 2026 at 2:44 am

    Copy of your code you showed me in the screencast:

    $("input[name='copyno']:checked").each(function() {
        checkboxData = "copyno="+$(this).val();
        ids = $(this).val();
    
        jQuery.ajax({
    
           url: "renewall.php",
           type: "POST",
           data: checkboxData,
           cache: false,
           dataType: "text",
           success: function(data) {
    
              var divs = $(data).filter(function() { 
                                           return $(this).is('#stil2'); //<-- add semicolon
              });
    
              divs.each(function() {
                 $("#" + ids).html(this);
              });
           }
        });
    });
    

    Anyway the important part is to properly declare your id variable within your click function like:

    $("input[name='copyno']:checked").each(function() {
        checkboxData = "copyno="+$(this).val();
        var ids = $(this).val();
    
        //rest of your code...
    
    });
    

    So do note that var instantiator right before the divs. This should fix your problem. If you don’t do this, the variable is set for the first call, but is overwritten by the second. So eventually when both calls finish, they will just have the same ids value which is your second div.

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

Sidebar

Related Questions

I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have this jQuery simple code: <script type=text/javascript> <!-- jQuery(function(){ jQuery('#old_thumb').click(function(){ $(this).val($(this).attr('title')); $('#sf').val('2'); $('#add_new_event').submit();
I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have problems with the following bit of javascript/jquery code: this.droppable = function(){ $('.imageWindow
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have this javascript code: if (navigator.userAgent.toLowerCase().indexOf(chrome) >= 0) { $(window).load(function() { $('input:-webkit-autofill').each(function() {
I have this jQuery code that queries an API on a keyup event (via
On my main page I have this jquery code which does an ajax call
I have this jQuery datepicker code that initially set the minDate of the datepicker.

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.