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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:30:13+00:00 2026-05-27T07:30:13+00:00

I am playing around with this page: http://www.problemio.com/problems/problem.php?problem_id=228 To reproduce the problem, log in

  • 0

I am playing around with this page: http://www.problemio.com/problems/problem.php?problem_id=228

To reproduce the problem, log in with this: testing@problemio.com / testing

Then click on the “comments” tab and click on edit wherever you see that option inside the edits tab. You will see that the <br /> are still there, but to create that edit form, here is the JavaScript I use to make the html for that form:

// Edit comment
$('.edit_comment').live('click' , function() 
{
    // Showing the wait image
    $("#loading").show();

    var problem_id = $(this).attr("data-problem_id");
    var problem_comment_id = $(this).attr("data-problem_comment_id");  
    var problem_comment_text = $(this).attr("data-problem_text");

    // problem_comment_text_'.$problem_comment_id.'
    var div_name = "problem_comment_text_" + problem_comment_id;
        //var dataString = 'problem_id='+ problem_id + '&problem_comment_id=' + problem_comment_id;

    // Now validate the input
        if( problem_id == '' || problem_comment_id == '' )
        {
       //$('#add_message_success').fadeIn(200).hide();
        //$('#add_message_error').fadeOut(200).show();          
        }
        else
        {   
            // Check if the person is logged in.
            // Now check if the person is logged in.
        $.ajax({
                type: "POST",
                url: "/auth/check_login.php",
                dataType: "json",
                success: function(data)
                {
                    $("#loading").hide();

                    // 1) close that piece of HTML
                    $("#" + div_name).hide();  // Works

                    problem_comment_text = problem_comment_text.replace(/\n/g,"<br />");

                // 2) Make an HTML form and display it in that piece of HTML
                var new_comment_form = "<form id='add_comment' method='post'><textarea name='problem_comment' cols=60 rows=6 id='problem_comment'>" + problem_comment_text + "</textarea><input type='hidden' id='problem_id' name='problem_id' value='" + problem_id + "' /><input type='hidden' id='problem_comment_id' value='" + problem_comment_id + "' /><input type='submit' class='button' value='Edit Message' /><input type='button' class='button' id='cancel_comment' data-problem_id='" + problem_id + "' value='Cancel' /></form>";

                // Now replace the current form with the crap I made above.
                $("#" + div_name).html( new_comment_form );  // Works
                $("#" + div_name).show(  );  // Works

                // 3) Hide the other text area form.
                $("#comment_bottom_text").hide(); // TODO - MAKE THIS WORK
                $(".comment_form").hide();                                              
            },
            error: function(json) // Error for checking if user is logged in.
            {
                // Showing the wait image
                $("#loading").hide();                    

                $("#loginpopup").dialog();

                return false;           
            }
    });
    }         

 return false;
});     

So you see I try to replace the <br /> with \n and it kind of works, but if you do the same thing again with the same comment, it places </a> tag in there. Any idea why that happens and how to stop it? Its weird because it happens on the second time editing a comment and not the first.

  • 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-27T07:30:13+00:00Added an answer on May 27, 2026 at 7:30 am

    You can do this to help you replace <br> with \n:

    problem_comment_text.replace(/<br>/gi, '\n');
    

    Hope it helps.

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

Sidebar

Related Questions

I've been playing around with this page adding CSS3 styles and all. http://daokun.webs.com/jQuery/Progress.html The
I am playing around with HTML 5 apps according to this tutorial: http://sixrevisions.com/web-development/html5-iphone-app/ It's
I was playing around with this code. http://programmersvoice.com/tag/code And I noticed that the following
I've been playing around with http://nixboxdesigns.com/projects/jquery-lavalamp/ for a navigation menu on a new site
I was playing around with some chrome extensions and I found this example: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/pageAction/pageaction_by_url/
I've been playing around with Troy Goode's PagedList http://pagedlist.codeplex.com/ . I was wondering if
Playing around with generating text randomly with each page refresh using php. Is there
I need to do rewrites so that the pages: http://www.site.com/page-one http://www.site.com/page-two http://www.site.com/page-three http://www.site.com/page-four Are
Been playing around with this for a couple of hours and can't seem to
I've been playing around with this for a couple of hours and have come

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.