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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:28:28+00:00 2026-06-12T23:28:28+00:00

I have a text area (from which I take a number) and button to

  • 0

I have a text area (from which I take a number) and button to submit the value, and I’m trying to add content to a paragraph that is generated by this loop:

var countNum = document.getElementById(num).value;
var entNum = parseInt(countNum);

for(i=1;i<=entNum;i++){
    if(i%3!==0 && i%7!==0){
       document.write(i + "<br>");
    }
}

now when i use document.write of course the whole previous content is overwritten, but I want to have a paragraph under the button, that receives the generated numbers from the loop and them. What’s the right way to do it ?

  • 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-12T23:28:29+00:00Added an answer on June 12, 2026 at 11:28 pm

    Lets assume you have a container below your button, where you’ll put your stuff in:

    <button [...] />
    <div id="myContainer"></div>
    

    Then you can fill the container by calling

    var myContainer = document.getElementById("myContainer");
    var paragraph = document.createElement("p");
    paragraph.appendChild(document.createTextNode("YourNumberOrTextHere"));
    myContainer.appendChild(paragraph);
    

    You’ll find out the rest! 😉


    EDIT:
    Following your comment, the following addition:

    To remove an element, you’ll need a reference to it.

    By ID:

    //Create element and give it a unique ID
    var paragraph = document.createElement("p");
    paragraph.id = "element1";
    //Now you can get it like this
    var paragraph = document.getElementById("element1");
    

    By TagName:

    //Request all elements with a certain tag name
    var paragraphs = document.getElementsByTagName("p");
    //or only those of our container:
    var paragraphs = document.getElementById("myContainer").getElementsByTagName("p");
    //Now you can mess with all of them like this:
    var paragraph = paragraphs[0]
    

    By Reference:

    //Just reuse the variable you used when you created your element
    var paragraph = document.createElement("p");
    //use paragraph
    

    More to find out:

    ;)
    

    NOW: Removing it:

    You have to tell the parentContainer that it should remove a child element. Fortunately, each element saves a reference to its parent:

    paragraph.parentElement.removeChild(paragraph);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does JavaFX 2.0 supports printing? I have a text area from which I take
I have a text area which is filled from database. In that textarea comma's
I have a text area page which is launched from the previous page: $message
I have a form on my website that takes input from a text area
I have a text area which I need to prevent from having javascript entered.
I have a text area in my form which accepts all possible characters from
I have a PHP page which accepts input from user in a text area.
If I have a variable that contains text information (say taken from a textarea),
I have a text area in a form that has a character limit and
Possible Duplicate: Capture newline from a textarea input I have a text area where

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.