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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:54:48+00:00 2026-06-13T09:54:48+00:00

I have a jquery script that accesses a db and returns a numeric result

  • 0

I have a jquery script that accesses a db and returns a numeric result and writes that result into a table cell. This scripts runs when the page loads but also when the drop down menu is changed. I want to be able to limit only 1 result per table cell.

Right now when page loads it writes the result to the cell and when the drop down menu is changed it just adds the new result to the cell instead of replacing it.

I have search quite a bit trying to figure out how to do this and can not come up with anything. Can someone help me?

Here is the jQuery:

$(document).ready(function(){

$('.typeval').change(function(){
    var movement    =  $(this).val();
    var client_id   = $(this).parent().siblings().find('.clientval').val();
    var class_id    = <? echo $class_id; ?>;
        $count      = $(this).parents('tr').find('label.count');

$.ajax({ 
  type: "POST",
  url: "movement_count.php",
  data: {movement:movement, client_id:client_id, class_id:class_id},
  dataType: "json", 
  async: false,
  success:(function(output) {      

      $.each(output, function(index, value){
     //alert(value);
     $count.append(output[index]);
     }); // each
     })     
}) // ajax

}).change(); // .typeval

});  // document

Here is the table cell where I only want to show one result at a time.

<td><label class="count">5</label></td>

Please let me know if I have not provided enough info for the assistance needed.

  • 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-13T09:54:49+00:00Added an answer on June 13, 2026 at 9:54 am

    Use .text() instead of .append():

    $count.text(output[index]);
    

    As its name implies, .append() adds the content to the end of the container. Whereas, .text() sets the text displayed in the container, overwriting any existing text.

    Actually, .html(), behaves more like .append() than .text() does, but I don’t recommend using .html() unless you are actually setting .html(). Since you said the result is numeric, .text() is better.

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

Sidebar

Related Questions

I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I have a jQuery script that returns a date as: Wed Nov 09 2011
Please refer to this page for reference: http://loadedgranola.valitics.com/_product_83484/blackberry_lime I have a jQuery script that
I have this jQuery script that sends a username an password to a PHP
i have this jquery script that changes the color of the background instantly by
i have this jquery script that clicks on link add info then hides it
I have a jQuery script that appends a row to a table. In short,
i have this jquery script that is meant to append input boxes, its wont
I have this jquery script that refreshes a div tag on my page: $(function()
I have a jQuery script that polls my server for new data, but it

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.