Q:

PhoneGap Forms add 2 numbers from Input Range sliders

I'm really new to JS and phonegap and I'm pretty stuck on adding 2 numbers and multiply it by a frequency selector RRfreq.
I can't seem to get any of the code to work I was just wondering if it was possible to read input range as an integer or floating point number.
Also, am I ready RRfreq correctly or do I need to code in something to read exactly what is selected.
Here the JavaScript:
<script type="text/javascript" language="JavaScript">
  function calcNumbers() {
    <!-- window.location='#stuff'; -->
    var hrs = document.getElementById("NumHours").value;
    var peeps = document.getElementById("NumPeople").value;
    var freq = document.getElementById("RRfreq").value;

    var ansD=document.getElmentById("answer");
    ansD.value= hrs * peeps;

    var x = (NumHours + NumPeople) * RRFreq;

    document.getElementById("demo").innerHTML = x;

    alert('testing');
  }
</script>

And here's what I have for my PhoneGap HTML:
<div id="Small Tank" data-role="page" data-theme="f">
<header data-role="header" data-position="fixed" data-id="appHeader">
    <h1>Tanks</h1>
    <a href="#homeScreen" class="ui-btn ui-icon-carat-l ui-btn-icon-notext ui-btn-left ui-nodisc-icon ui-alt-icon">Back</a>
</header>
<div data-role="content">

    <h1 class="center">Tanks</h1>

  <!--  <div id="form"> -->
    <!-- <form id="calcUsage" data-ajax='false'> -->
  <!--  <form method=post action="" id="calcUsage">-->
        <div data-role="fieldcontain">
            <label for="PeopleSlider">Number of People:</label>
            <input type="range" name="NumPeople" id="NumPeople" value="100" min="100" max="200" /> 
            <p>&nbsp;</p>
        </div>

        <div data-role="fieldcontain">
            <fieldset data-role="controlgroup" data-type="horizontal">
                <legend>Frequency of RR Usage in Hours</legend>
                <input name="RRfreq" type="radio" id="RRfreq_1" title="1" value="1" />
                <label for="RRfreq_1">1.0</label>
                <input name="RRfreq" type="radio" id="RRfreq_15" title="15" value="1.5" />
                <label for="RRfreq_15">1.5</label>
                <input name="RRfreq" type="radio" id="RRfreq_2" title="2" value="2" />
                <label for="RRfreq_2">2.0</label>           
            </fieldset>
             <p>&nbsp;</p>
        </div>

        <div data-role="fieldcontain">
            <label for="TimeSlider">Number of Hours:</label>
            <input type="range" name="NumHours" id="NumHours" value="1" min="1" max="8" /> 
        </div>
        <input type="submit" data-theme="f" name="submit" value="Calculate Usage" onClick="javascript:calcNumbers()">

        Answer= <input type="text" id="answer" name="answer" value="" />

   <!-- </form> -->
<!--    </div> --> <!-- form -->

</div>  <!-- content -->

I added in a redirect URL to see if I was even stepping into my function and I am-- I can't seem to get the alert message to pop-up though I think my pop-up browser might be stopping it. Any advice on debugging JavaScript running in PhoneGap would really be appreciated :)

A:

In general, the logic is fine. There are just a few things you need to correct on your HTML and Javascript to make this work.
On the HTML

Select a default radio button selected (this will prevent your calculation to crash because it will contain a value by default, is a good practice)
Change the type="submit" of your calculate button to type="button" this will prevent the page from reloading (if your intention is to make a post then leave it as type="submit"

On the Javascript
Here you can improve many things. I creade a JSFiddle for you to see how it works. Please read the comments on the Javascript.
https://jsfiddle.net/saq8yyv0/14/
Advice for debugging
You can easily debug Javascript running on your browser even if this is a phonegap application. I prefer Chrome for this. Just open the developer tools (ctrl+shift+i) and select the sources tab. Here you can find some documentation about it.
Here is a more extended list on tools and techniques to debug phonegap applications but in general you can do almost all your debugging using chrome developer tools

