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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:22:43+00:00 2026-06-07T23:22:43+00:00

I know this is a really simple question, but I need to replace this

  • 0

I know this is a really simple question, but I need to replace this bit of text in a paragraph with a variable every time an even fires.

The markup looks like this

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#container {width:100%; text-align:center; }
#heading {width:100%; text-align:center; }
</style>
</head>

<div id="heading">
<h1>hello</h1> 
</div> 
<body>
<div id="container">
<textarea name="mytextarea" cols="60" rows="40"></textarea>
</div>
</body>
</html>

What I need is where it says “hello” in the tags, is for that to be a variable that van be replaced by a string that I will generate.

  • 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-07T23:22:45+00:00Added an answer on June 7, 2026 at 11:22 pm

    One example on how can be simple things made complicated 🙂

    javascript:

    // simple way:
    function replace_text(text) {
        var heading = document.getElementById('heading');
        heading.innerHTML = '<h1>' + text + '</h1>';
    }
    
    // complicated way:
    function replace_text2(text) {
        var heading = document.getElementById('heading');
        var node = heading.childNodes[0];
        while ( node && node.nodeType!=1 && node.tagName!='H1' ){
            //console.log(node.nodeType,node);
            node = node.nextSibling;
        }
        if (node) {
            node.replaceChild(document.createTextNode(text),node.childNodes[0]);
        }
    }
    

    html:

    <input type="button" onclick="replace_text('HELLO 1!');" value="Replace 1st text" />
    <input type="button" onclick="replace_text2('HELLO 2!');" value="Replace 2nd text" />
    

    The script is here.

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

Sidebar

Related Questions

I know this is a really simple question but my google-fu is failing me.
I know there must be a really simple answer to this question, but I
I know this might be really a simple question but I don't know the
I feel like this is a really simple question, but I need help figuring
This is probably a simple question, but I really don't know what I'm doing
I know this probably really simple but Im not sure what im doing wrong...
I know this is really simple but I cant find the docs for this
I know this is a really basic question but I've been searching the internet
I know this isn't a straightforward question but I would really appreciate some feedback
I know this question might be repeated many times but would really appreciate any

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.