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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:08:17+00:00 2026-06-10T00:08:17+00:00

I have tested the following script is working in my PHP page: <script> function

  • 0

I have tested the following script is working in my PHP page:

<script>
  function calculate<?=$performance_item_id;?>(){
    alert('<?=$performance_item_id;?>');
    $.post('complete_calculate.php',{
      tid: document.getElementById('performance_item_id<?=$performance_item_id;?>').value
    },
    function(output){
      $('#complete_percentage<?=$performance_item_id;?>').html(output);
    });
  }
  calculate<?=$performance_item_id;?>()
</script>
<span id='complete_percentage<?=$performance_item_id;?>'></span>

First, I would like to change the post value to something like "$('.complete<?=$performance_item_id;?>').val();", that is, not get something from an id field, but gather values from several fields having the same class.

Second, I would like to use a text box to hold the HTML output, while “<input type = "text" id='complete_percentage<?=$performance_item_id;?>' name = "complete_percentage[]" size = "5" value="0">” is not working! Please help! Thanks!

  • 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-10T00:08:18+00:00Added an answer on June 10, 2026 at 12:08 am

    Your question is not very clear, but here are a few points to consider:

    1. There’s no need to constantly intermingle your PHP with the JavaScript.
      Store the value of $performance_item_id in a JavaScript variable, then re-use that.

    2. There’s no need to declare a function and then immediately call it.
      You can use the (function(){}()) pattern* to execute your code immediately.

    3. Use jQuery’s .map() and .get() functions to get an array of all the values.

    (function () {
        var id = '<?=$performance_item_id;?>';
        alert(id);
    
        $.post('complete_calculate.php', {   
            tid: $('.complete' + id).map(function(){ return this.value; }).get()
        }, function(output) {
            $('#complete_percentage' + id).html(output);
        }); 
    }());
    

    * Called either a Self Executing Annonymous Function or an Immediately Invoked Function Expression.


    After further clarification, it seems you don’t need any PHP in your JavaScript:

    jQuery(function($) {
        $('[class^=complete_]').keyup(function() {
            $.post('complete_calculate.php', {   
                tid: $('.' + this.className).map(function(){ return this.value; }).get()
            }, function(output) {
                $('#complete_percentage' + this.className.replace('complete', '')).html(output);
            }); 
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tested the below script on a demo page which is not using
I have the following code on an html page: <script type=text/javascript> <!-- window.location.replace(http://www.example.com/); -->
I have the following JS code on my site: function foo(link) { alert('ID=' +
Why doesn't following code work correctly in FireFox 3.6? I have tested in IE7,
I would like to have a button on a web page with the following
Following is the Java Script code i have. //URL = http://dev.stage.com/restapi/vc/auth/sessions/login/ //parametersURL = user.login=******&user.password=******
My goal for this project is to have this script perform the following: 1-
I have the following code that I have tested and works: using (new Impersonator(Administrator,
I have the following very simple Ext JS 4 script which is supposed to
I have the following code that I'm trying to get working. What I want

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.