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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:15:22+00:00 2026-06-18T19:15:22+00:00

Searched far and wide here, but can’t seem to find the answer! This is

  • 0

Searched far and wide here, but can’t seem to find the answer!
This is homework! So I do not expect anyone to write anything for me, just to help me 🙂

I am attempting to have a HTML message box with a post button. When the post button is clicked, the message, along with the date is posted into a div bellow. This can be done many times, with the newest ones being published under the oldest ones. The way I am trying, is to create a new div every time, and assign them all to the same class that is in my CSS document. The message and date must be in separate ‘p’ tags with their own class assigned. If anyone knows a better approach, I’m all ears. Although, my Javascript document must be external.

I currently have this code:

function createComment(){
var message = "";
var divTag = document.createElement("div");
divTag.className = "commentDiv";
divTag.innerHTML = Date();
message=document.getElementById("textBox").value;
document.getElementById("comments").innerHTML=message;
}

I am attempting to create the div, then give it an ID of ‘commentDiv’, since that is the div ID in my CSS document that is already styled. I then post the date in the inner HTML, and save the value from the text box into a variable, named ‘message’. I then try to attempt to print the message into a paragraph tag with the ID of ‘comments’. I am VERY new to web Javascript. So honestly, I don’t really know what I’m doing haha.
All help is greatly appreciated. Thanks!

  • 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-18T19:15:23+00:00Added an answer on June 18, 2026 at 7:15 pm

    I think what you are looking for is something like

    var ct = document.getElementById('comments')
    
    function create(){
        var divTag = document.createElement('div');
        divTag.className = 'comment';
    
        var p1 = document.createElement('p');
        p1.className = 'date';
        p1.innerHTML = new Date();
        divTag.appendChild(p1)
    
        var p2 = document.createElement('p');
        p2.className = 'message';
        p2.innerHTML = 'nop';
        divTag.appendChild(p2);
    
        ct.appendChild(divTag);
    }
    

    Demo: Fiddle.

    The appendChild() can be used to append child element to a node.

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

Sidebar

Related Questions

I have searched high, low, far and wide but can not find anything on
I searched this on the internet, but could not find any answer. I want
Good day, I have searched far and wide but all I can find is
I have searched around for an answer to this but can't find one. When
I searched far and wide looking for the answer to this but nothing seems
I've searched far and wide and I hope someone can answer this question. I'm
I have searched far and wide on the Internet but have not found anything
I've searched far and wide for suggestions and solutions to this problem, but I'm
I've searched far and wide for the javax.comm package, but I cannot find it
Ok I've searched far and wide and can't find a solution that I can

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.