mercredi 29 novembre 2017

If, else if statement not working (only displays if)

It only displays the if statement doesn't get to the 2nd or the 3rd statement would appreciate some help :) THE HTML portion only displays out the "commentE" value sorry for the poor formatting :(

        var totalAmount = (conversion * sAmount);
        totalAmount = $("#totalAmount").val(totalAmount);

        var myadvice;
        myadvice = $("#myadvice").val();

        var great;
        great = localStorage.getItem("great");


        var commentE;
        commentE = localStorage.getItem("commentE");

        var between;
        between = localStorage.getItem("between");

        var betweenb;
        betweenb = localStorage.getItem("betweenb");

        var commentB;
        commentB = localStorage.getItem("commentB");

        var less;
        less = localStorage.getItem("less");

        var commentL;
        commentL = localStorage.getItem("commentL");


if (totalAmount >= great) {
    myadvice = $("#myadvice").val(commentE);
} else if ((totalAmount >= between) && (totalAmount <= betweenb)) {
    myadvice = $("#myadvice").val(commentB);
} else if (totalAmount <= less) {
    myadvice = $("#myadvice").val(commentL);

These are the HTML portion (index page to get input)

   <div data-role="navbar">
                            <ul>
                                <li>
                                    <label for="between">Between</label>
                                    <div class="ui-grid-a">
                                        <div class="ui-block-a">
                                            <input type="text" 
  name="between" id="between" placeholder="between" value="200">
                                        </div>
                                        <div class="ui-block-b">
                                            <input type="text" 
  name="betweenb" id="betweenb" placeholder="between" value="499">
                                         </div>
                                    </div>
                                </li>
                                <li>
                                    <label for="commentB">Comment</label>
                                    <input type="text" name="commentB" 
  id="commentB" placeholder="comments" value="OK">
                                </li>

                            </ul>
                        </div>

These are supposed to be the results (results page to display the input of previous page

   <div data-role="main" class="ui-content">
    <div class="ui-field-contain">
        <div data-role="fieldcontainer">
            <label for="advice"> My Advice is as follows: </label>
            <input type="text" name="advice" id="advice">
        </div>
    </div>
 </div>

Aucun commentaire:

Enregistrer un commentaire