jquery mobile javascript calculator for phonegap
I am very new to javascript, and I am trying to build a mobile app with Jquery Mobile. I would like the user to input one value on each page and then on the last page they will click submit and it will display the calculated value on the last page. I have been working on this for like 4 hours and I can get the calculation to work on the same page as the submit button but not on the next page.
<script> function sum() { var item1num = document.getElementById('item1num').value; var item2num = document.getElementById('item2num').value; {result = parseInt(item1num)*parseInt(item2num); document.getElementById("showResult").innerHTML = (result);}} </script> </head> <body> <!-- Home --> <div data-role="page" id="page1"> <div data-role="content"> <div data-role="fieldcontain" id="item1"> <fieldset data-role="controlgroup"> <label for="item1"> item1 </label> <input name="item1num" id="item1num" placeholder="" value="" type="number" /> </fieldset> </div> <a data-role="button" data-transition="slidefade" href="#page2" data-theme="b"> Next </a> </div> </div> <div data-role="page" id="page2"> <div data-role="content"> <div data-role="fieldcontain" id="item1"> <fieldset data-role="controlgroup"> <label for="item2"> item2 </label> <input name="item2num" id="item2num" placeholder="" value="" type="number" /> </fieldset> </div> <input id="btnAdd" type="submit" value="Submit" onclick="sum();" data-theme="b" /> <span id="showResult"></span> </div> </div> <div data-role="page" id="page3"> <div data-role="content"> <span id="showResult"></span> </div> </div>