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

  • Home
  • SEARCH
  • 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 6882519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:15:48+00:00 2026-05-27T05:15:48+00:00

I convert user input urls to bbcode and append it to the textarea, but

  • 0

I convert user input urls to bbcode and append it to the textarea, but after you delete one of the lines I appended it won’t append more(but you could see the newly appended values in the firebug,really strange).Here’s my code:

$(function(){
    $(".addUrl").click(function(){
        $("#addUrl").slideDown();
    })
    $('#su').click(function(){
        if($("#u").val().length>3)
        addUrl($("#u").val());
        $("#u").val("");
    })
    $("input[value=\"x\"]").click(function(){$("#addUrl").fadeOut();})
})
function addUrl(e)
{
    patt="http[s]*:\/\/";
    if(e.match(patt))
        u=e;
    else
        u="http://"+e;
    $("textarea[name=\"content\"]").append("\n\r[url]"+u+"[/url]\n\r");
}

And here’s the jsfiddle:http://jsfiddle.net/FpSsc/

  • 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-27T05:15:49+00:00Added an answer on May 27, 2026 at 5:15 am

    It’s because you are changing the html inside the textarea which is the default value. It seems that as soon as you have set a new value (by typing or deleting something from the textbox) this default value is ignored.

    To get round this you need to set the value of the textarea rather than append to the content:

    function addUrl(e)
    {
        patt="http[s]*:\/\/";
        if(e.match(patt))
            u=e;
        else
            u="http://"+e;
    
        var newVal = $("textarea[name=\"content\"]").val() + "\n\r[url]"+u+"[/url]\n\r"
        $("textarea[name=\"content\"]").val(newVal);
    }
    

    http://jsfiddle.net/infernalbadger/FpSsc/1/

    Or as Felix recommended:

    function addUrl(e)
    {
        patt="http[s]*:\/\/";
        if(e.match(patt))
            u=e;
        else
            u="http://"+e;
    
        $("textarea[name=\"content\"]").val(function(i, v) { return v + "\n\r[url]"+u+"[/url]\n\r"; });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert user input that comes as Map<String, String[]> to objects in
I am trying to convert the user's input from the EditText into a Big
I want to convert a floating point user input into its integer equivalent. I
I have a <textarea> for user input, and, as they are invited to do,
There are times when I want to convert user input into its literal value
I need to be able to convert user input to [a-z] roman characters ONLY
Is there a POSIX way how to convert a user input with UTC offset
I need a way in c# or javascript to convert any input user has
I try to generically convert user input into either simple or complex types: class
I'm trying to convert data from one text input (form) into an array so

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.