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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:20:50+00:00 2026-06-14T19:20:50+00:00

so far I have this jsfiddle <p>Click the button to remove http:// and www.

  • 0

so far I have this jsfiddle

<p>Click the button to remove http:// and www. from input box belove below:</p>

<textarea id="demo" name="comments" cols="25" rows="5">
    http://www.google.com
</textarea><br>
<input type="submit" value="Submit" button onclick="myFunction(),myFunction2()" />
</form>

<script>
function myFunction()
{
    var str=document.getElementById("demo").innerHTML; 
    var n=str.replace("http://","");
    document.getElementById("demo").innerHTML=n;
}

function myFunction2()
{
    var str=document.getElementById("demo").innerHTML; 
    var m=str.replace("www.","");
    document.getElementById("demo").innerHTML=m;
}
</script>​

It works fine with the text pre input but it will not change submitted text.
I’m sure there’s a simple answer, I’m just new to this and cannot work it out or find an answer.

  • 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-14T19:20:53+00:00Added an answer on June 14, 2026 at 7:20 pm

    You need to use .value of the textarea, not .innerHTML.

    .innerHTML only looks at the generated HTML in an element. If the user types in something new, the source doesn’t change.

    But, the value does:

    document.getElementById("demo").value = ...
    

    Fixed in your fiddle:

    http://jsfiddle.net/AbSh2/12/

    A couple other pointers:

    • You don’t need two functions to do that operation, as you can see it can be done in one.
    • You could use type='button' instead of a submit, since Javascript doesn’t care about form submits (that only matters on the server, which receives POST and GET data. Javascript can’t)

    You can streamline your function even further without saving strings all over the place:

    function myFunction() {
        var str=document.getElementById("demo").value;
        var n=str.replace("http://","");
        var m=n.replace("www.","");
        document.getElementById("demo").value=m;
    }
    

    works fine. You could even do

    function myFunction() {
        document.getElementById("demo").value = 
            document.getElementById("demo").value.replace("http://","").replace("www.","");
    }
    

    but that gets a little jumbled IMO, so should be for learning purposes only 🙂

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

Sidebar

Related Questions

I have this so far: http://jsfiddle.net/u5vhS/54/ . What I want to be able to
I have been trying to get this jsfiddle to work. So far without luck.
I have a form with input fields and the client can click a button
I have this fiddle: http://jsfiddle.net/tatygrassini/tZBXe/ Horizontal dropdown menu with a 1 level deep submenu.
So far i have this: mov ah,02h mov cl,11001100001111011101000b ;6,692,584 in dec mov dl,0
Thanks to everyone out there helping newbies like me. So far I have this:
I have this so far but the Column 'name' is ambiguous, so I want
I have this so far but I don't know how to write over the
I have this code so far which perfectly but relies on there being a
I have this trigger which works functionally (as far as I can tell by

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.