0
<!DOCTYPE html>
<html lang="en">
<head>
<title> Chess Org Membership</title>
<meta charset="utf-8">
</head>
<body>
<h3 id="myHeader"></h3>
    
    <script>
        myHeader.innerText = "Customer Information";
    </script> 
    <script>
        
      
        const username = (prompt("What is Your Name?"));
   
        const address = (prompt("What is Your Mailing Address?"));
        
        const phone = prompt("What is Your Phone Number?");
        
        const email = prompt("What is Your Email Address?");
            
        const mem = prompt("What is The Number Of Memberships That You Purchased?");
        
            const html = `<p><label>Name: </label>${username}</p>
                <p><label>Address: </label>${address}</p>
                <p><label>Phone: </label>${phone}</p>
                <p><label>Email Address: </label>${email}</p>`;
            document.write(html);
    </script>
    
<h3 id="myHeader2"></h3>

    <script>
        myHeader2.innerText = "Order Information";
    </script>
    
    <script>
        
        
        const mem;
        const cost= 30;
        const total= parseInt(mem * cost);
        
        
        const html = `<p><label>Number of Memberships: </label>${mem}</p>
                        <p><label>Cost per membership: </label>${cost}</p>
                        <p><label>Total Cost: </label>${total}</p>`;
                document.write(html);
    
    </script>
    

    
  
</body>
</html>

I need to create a document displaying order information. The first section of document.write outputs correctly underneath the Customer Information, but I cannot figure out how to get the second section to display under Order information. Number of memberships purchased, cost of membership, and total cost need to be displayed under Order information. I can get everything to be displayed correctly under Customer information, so I know the code is partially correct. When I move the second document.write for the order information into its own <script></script> tags it won't display

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • https://developer.mozilla.org/en-US/docs/Web/API/Document/write: _"Note: Because document.write() writes to the document stream, calling document.write() on a closed (loaded) document automatically calls document.open(), which will clear the document."_ You should not be using document.write for this at all. Either populate already existing elements with content dynamically (innerHTML/innerText), or use DOM methods to create and append elements to the document dynamically. – CBroe Nov 02 '22 at 15:07

0 Answers0