HTML / Javascript help

Discussion in 'Web Design and Development' started by Croatian, May 20, 2010.

  1. Croatian macrumors 6502

    Oct 14, 2006
    Ontario, Canada
    Here is my problem

    i have a javascript that calculates values that are inputed in a form. For example, how much your food costs, so you put in lunch value, dinner, beakfest and so and and press calculate button and it spits out the value for you.

    All that works fine, no problems.

    Now where i run into a problem is when i click calculate button i want it to to go onto a new page (so i have results displayed there) and i can't seem to figure out how to do that.

    Here is the code i have for the button right now

    <input class="buttonx gray" type="button" name="btncalculate" id="btncalculate" value="calculate" onClick="populateform()" a class="revealme"  />
  2. angelwatt Moderator emeritus


    Aug 16, 2005
    The fundamental issue is that HTML is stateless, meaning that calculations on one page are independent of loading another page. You'll need to pass along the results to the new page if you want it displayed there. You can do this with GET arguments in the URL, or use sessions through a server side language like PHP, or you could even use cookies.

    I don't really know that you need a new page to show the results. It could be easier to a pop-over using JavaScript that show the results on top of the page, or just show it under the form where they are entering info.

    On you code snippet, you have some issues, you have two class attributes, and a "a" in there that does nothing but invalidate the syntax.

Share This Page