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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:15:29+00:00 2026-05-29T18:15:29+00:00

I am trying to write code for a task form which shows the task

  • 0

I am trying to write code for a task form which shows the task and it’s status. This is my form.

enter image description here

If i click the status content a select menu will appear with the three options Completed,In Progressand Waiting for client confirmation. If i select an option and press enter it will be updated in the database. If the status is updated as completed then the select box should not display on the click event. My problem is if i updated the status to complete and then click the same status the select menu appears. But if i modified and refresh the page it works fine. I need it to be correct with out refresh the page.

This is my php code

<?php
            if($fetchstatus == 'Completed'){
            echo 'Completed';
            }
            else{?>
            <span id="status"><?php echo $fetchstatus; ?></span>
            <select id="<?php echo $fetchtaskid; ?>" style="width:110px;">
            <option value="In progress">In progress</option>
            <option value="Completed">Completed</option>
            <option value="Waiting for client confirmation">Waiting for client confirmation</option>
            </select>
            <?php
            }
            ?>

This is my ajax script

$(document).ready(function(){
        var eventFlag=false;
        var originalText='';
        $('.updatetask tr td span#status').click(function(e){
            e.stopImmediatePropagation();
            $(this).siblings().show().focus();
            $(this).hide();
            eventFlag=false;
            originalText=$(this).siblings().val();
        });

        $('.updatetask tr td select').blur(function(e){
            if(!eventFlag && validate($(this))) doAjax($(this));
            else
            {
                $(this).siblings().show();
                $(this).hide();
            }
        });

        $('.updatetask tr td select').keypress(function(e){
            e.stopImmediatePropagation();
            var code = (e.keyCode ? e.keyCode : e.which);
            if(code==13)
            {
                if(validate($(this)))
                {
                    doAjax($(this));
                    eventFlag=true;
                }
                else
                {
                    $(this).siblings().show();
                    $(this).hide();
                }
            }
        });

        function validate(input)
        {
            console.log(input.val()+" "+originalText);
            if(input.val()!='' && input.val()!=originalText)
            return true
            else return false;
        }

        function doAjax(input)
        {
            var formData="proId="+input.attr('id')+"&text="+input.val();
                $.ajax({
                    type: "POST",
                    url: "update_taskstatus.php",
                    data: formData,
                    success: function(data){
                        if(data==1) 
                        {
                            input.siblings().text(input.val()).show();
                            input.hide();
                            if(input.val()=='completed')
                            {
                                input.siblings().unbind('click');
                            }   
                        } 
                        else
                        {
                            input.siblings().show();
                            input.hide();
                            alert("something Wrong !");
                        }   
                    },
                    error:function (xhr, ajaxOptions, thrownError){
                        alert("Error:"+xhr.status+" "+thrownError);
                    }
                });
        }

    });

How can i correct that?

  • 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-29T18:15:35+00:00Added an answer on May 29, 2026 at 6:15 pm

    As you’ve changed my code that I gave you yesterday so I’m a little bit confused and not sure whether my current code will work or not but from my guess try this and let me know the result

    if(data==1) 
    {
        input.siblings().text(input.val()).show();
        input.hide();
        if(input.val()=='Completed')
        {
            input.siblings().unbind('click');
        }   
    }
    

    Change the do ajax function, only the first if block, hope it’s clear enough.

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

Sidebar

Related Questions

I'm trying to write code that will load an image from a resource, and
I'm having some trouble with this code. I am trying to write a function
I was trying to write code that would auto-close a Toplevel Tk window in
Really stuck on trying to write code to unzip a file or directory on
I've been trying to write code that loads a .png file, attaches hotspot information,
I'm trying to write some code to find a specific XmlNode object based on
I'm trying to write some code to work with an htdigest password file. The
I was trying to write some code that would check if an item has
I'm trying to write some code using pure SQL using ASP.NET MVC. I assume
I'm trying to write some code to Hide columns if the first 3 characters

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.