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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:22:55+00:00 2026-06-13T20:22:55+00:00

My question is why when i click the button the only thing getting shown

  • 0

My question is why when i click the button the only thing getting shown is this “Pricelist” and all the other lines with variables in it get omitted.

function showmessage() {
    var sendcost, totalcost;
    if (document.pricelist.total.value<11) {
        sendcost = 3; 
    }   
    else {
        sendcost = 2; 
    }   
    if (document.pricelist.option.checked) {
        sendcost = parseInt(document.pricelist.option.value) + parseInt(sendcost);
    }
    totalcost = parseInt(sendcost) + parseInt(document.pricelist.total.value);

    document.write("Pricelist","</br>");
    document.write("Products price: "+document.pricelist.total.value+"</br>");
    document.write("Send fee: "+sendcost+"</br>");
    document.write("Total cost: "+totalcost+"</br>");
}
<form name="pricelist">
Tuna Salad = 4 <input type="checkbox" name="choice" value="4" onchange="checkTotal()" /></br>
Pasta = 13 <input type="checkbox" name="choice" value="13" onchange="checkTotal()" /></br>
Milk = 3 <input type="checkbox" name="choice" value="3" onchange="checkTotal()" /></br>
Chocolate = 2 <input type="checkbox" name="choice" value="2" onchange="checkTotal()" /></br>
Same day delivery<input type="checkbox" name="option" value="5" /></br>
Total: <input type="text" size="2" name="total" value="0"/>
<input type="button" value="Procceed to checkout" onclick='return showmessage();' />
  • 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-13T20:22:57+00:00Added an answer on June 13, 2026 at 8:22 pm

    document.write when called after the page loads will destroy the entire page, therefore there will be no form with name pricelist anymore therefore document.pricelist.total.value will cause Uncaught TypeError: Cannot read property 'total' of undefined, which causes your script to terminate prematurely.

    I’d suggest using something other than document.write.

    But to avoid the current error just save the value of document.pricelist.total.value to a variable before its destroyed.

    var value = document.pricelist.total.value;
    document.write("Pricelist","</br>");
    document.write("Products price: "+value+"</br>");
    document.write("Send fee: "+sendcost+"</br>");
    document.write("Total cost: "+totalcost+"</br>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to this question (click me!) , I have the Source property of my
jQuery: // ACCORDION $('.accordion .answer').hide(); // hide all $('.accordion .question').click(function(){ $('.accordion .answer').slideUp(); // hide
This is a 2 part question: 1) click on one of the demo dropdowns
This is basically the same question as Click items in select box, and then
I asked a precursor to this question here: Click link in DIV and show
I have this simple JSF button: //Question Dialog function deletedialog(button, a){ $(<div />, {
A bit new to this whole web development thing still. This question will be
Question: I am trying to fire a .click() event if a <ul></ul> element has
I have a little question I want to click on my smileys and insert
a simple question here Is there a way to change the text click here

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.