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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:44:14+00:00 2026-05-31T01:44:14+00:00

The basics of the functions work, but for every cancel button thats clicked, the

  • 0

The basics of the functions work, but for every cancel button thats clicked, the next button will add that number of clicks to it. For example if a user clicks a cancel button once, then next time a different button with a different id is clicked, firebug shows the page that contains the form (page2) to load that many times, instead of once. This all generated dynamically, so there may be up to 10 of these div’s on the parent page. What should happen is:

  1. user clicks the readonly textbox on the parent page
  2. onfocus empties that div from parent page and loads the child page
    3.form from the child page is in the readonly’s textbox space now
  3. user either submits a comment or cancels
  4. either action should put the readonly textbox back in the page
    (up to this point, this all works)
  5. when pressing another div to leave a comment that page should only load once, not as many times from clicking the previous buttons.

In the 1st page I have:

<head>
    <script type="text/javascript">
        $(document).ready(function(){
            var ajaxInProgress = false;
            $(function(){
                if (ajaxInProgress) return;
                $('.ce').focus(function(){
                    var cid = this.id;
                    $('#comfield'+cid).empty();
                    $('#comfield'+cid).load('content_comment.php?id=<%=intmemberid%>&cid=' + cid);
                });
            });
    </script>
</head>
<body>

    <div id="comform"
        <div id="comfield2">
            <input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />
        </div>
    </div>
    <div id="comdata2"></div>

    <div id="comform"
        <div id="comfield3">
            <input class="ce" id="3" type="text" value="Write a comment..." readonly="readonly" />
        </div>
    </div>
    <div id="comdata3"></div>

</body>

In page 2 I have

<script type="text/javascript">
    $(document).ready(function() {

        document.commentform2.comment.focus();

        $("#cancelcomment2").click(function(){
            $('#comfield2').empty();
            $('#comfield2').html('<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />');
            var ajaxInProgress = false;
            $(function(){
                $('.ce').focus(function(){
                    if (ajaxInProgress) return;
                    var cid = this.id;
                    $('#comfield'+cid).empty();
                    $('#comfield'+cid).load('content_comment.php?id=55&cid=' + cid);
                });
            });
        });

        $("#submitcomment").click(function(){
            $('#formcomment').ajaxForm(function (data, textStatus){
                $('#formcomment').clearForm();
                $('#comfield2').empty();
                $('#comfield2').html('<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />');
                $('#comdata2').append(data).fadeIn(700);
                var ajaxInProgress = false;
                $(function(){
                    if (ajaxInProgress) return;
                    $('.ce').focus(function(){
                        var cid = this.id;
                        $('#comfield'+cid).empty();
                        $('#comfield'+cid).load('content_comment.php?id=55&cid=' + cid);
                    });
                });
            });
        });

    });
</script>

<form id="formcomment">
    <textarea id="commenttext2>" name="comment" class="commentarea"></textarea>
    <input type="submit" id="submitcomment" value="comment />
    <button id="cancelcomment2">Cancel</button>
</form>
  • 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-31T01:44:16+00:00Added an answer on May 31, 2026 at 1:44 am

    This may not be the “best” way to do it, but it will work.

    replace all occurences of

    $('.ce').focus(function(){
    

    with

    $('.ce').unbind("focus").focus(function(){
    

    in both scripts.

    The better way would be event delegation, though that will take more changes to the code.

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

Sidebar

Related Questions

The company I work for currently uses some basic functions to abstract the OCI
I'm currently working on a (relatively) basic web application that functions as a time
thus far i've only been using some basic jquery selectors and functions. but i'm
At work, we are developing an PHP application that would be later re-programmed into
I try to make a little program that sorts an array using threads but
I'm trying to memoize a member function of a class, but every time the
I don't know why this is erroring, but I'm just trying to add something
Let's say I have a text file of basic mathematical functions. I want to
Some question on java basics, the below function returns an object of Node type
I've noticed some problem with va_start when call successively in two functions. A basic

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.