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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:36:14+00:00 2026-06-03T09:36:14+00:00

I have been strugling with this for a while and I am sure there

  • 0

I have been strugling with this for a while and I am sure there is a simple answer to this. What happens is I remove a div called “payment” then dynamicaly create it again so I can add to it. That then gets repeated as the infomation that needs to be added to it changes.

I have mangaged to get this so far.

function clearPage()
{
    var d = document.getElementById("contain"); 
    var d_nested = document.getElementById("payment"); 
    var deleteNode = d.removeChild(d_nested);

}

function createPayment()
{
    payment = document.createElement("div");
    payment.id = "mine";
    document.getElementById("contain").appendChild(payment);
}

function printOnPage()
{
    var x = names.length;
    for( var i = 0 ; i < x ; i++ )
    {
        var para = document.createElement("p");
        var paymentDiv = document.getElementById("payment");
        paymentDiv.appendChild(para);
        var txtName = document.createTextNode("Item: ");
        para.appendChild(txtName);
        var txtNameArray = document.createTextNode(names[i]);
        para.appendChild(txtNameArray);
        var txtQty = document.createTextNode(" Qty: ");
        para.appendChild(txtQty);
        var txtQtyArray = document.createTextNode(qty[i]);
        para.appendChild(txtQtyArray);
        var txtCost = document.createTextNode(" Cost: ");
        para.appendChild(txtCost);
        var txtCostArray = document.createTextNode(prices[i]);
        para.appendChild(txtCostArray);
    }
}

Related HTML

<div id="contain">
    <p>Payment</p>
        <div id="payment">  
            <br />
        </div>
</div>

It needs the ID of payment for both my CSS rules and for my creating the text that goes in it.

This is the error I get in FireFox

Error: paymentDiv is null Source File:
http://itsuite.it.brighton.ac.uk/ks339/sem2/javascript/js.js Line: 76

Hope someone can provide some insight in to this and please tell me if I am completly off!

Thanks

Edit: Is it easior to clear the div rather than delete it, how would I go about doing such a thing?

  • 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-03T09:36:16+00:00Added an answer on June 3, 2026 at 9:36 am

    In create_payment(), you set the ID to ‘mine’. Shouldn’t it be ‘payment’?

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

Sidebar

Related Questions

I have been struggling with this for a while and can't find the answer
I've been struggling with this issue for a while now. I have OpenCart 1.5.2.1
I have been struggling to find an answer to this theoretical question, even tho
I have been struggling with this for a while and just can't work it
Ive been struggling for a while with my rather simple app. This is my
I have been struggling with this a while now. I implemented a basic IHttpHandler
I have been struggling with this for a while, so I hope some of
I have been struggling with this for a while and could really use some
I have been struggling with this piece of code for a while and I
I have been struggling with this for a while now. I have a Master

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.