I'm adding values from select lists (or subtracting) and I can't seem to make it not concatenate the string.
My select list is:
<li class="extraHeight">
    <asp:Image runat="server" CssClass="iconImageMove" ID="Image13" ImageUrl="~/images/icons/ABabyChg_Off.png" />
    <div class="flipWidth">
        <select name="access" class="change" id="ABabyChg_Off"  runat="server">
            <option value="16777216">Off</option>
            <option value="16777216">On</option>
        </select>
     </div> <br /> <p class="noWrap">Accessible baby changing facilities</p>
</li>
<li class="extraHeight">
    <asp:Image runat="server" CssClass="iconImageMove" ID="Image14" ImageUrl="~/images/icons/carpark_off.png" />
    <div class="flipWidth">
        <select name="access" class="change" id="carpark_off"  runat="server">
            <option value="256">Off</option>
            <option value="256">On</option>
        </select>
     </div> <br /> <p class="noWrap">Accessible Car parking facilities</p>
</li>
And my javascript is:
<script>    
        $("select").change(function () {
           var currentAccess = "0";
           var currentText = $(":selected", this).text();
           var value = $(this).val()
           alert(currentAccess);
            if(currentText == "Off")
                    {
                        currentAccess -= value;
                    }  
            if(value != "0") {        
            if(currentText == "On")
                     {
                        currentAccess += value;
                     }
            }
              $.cookie("accessReqs",  currentAccess, { expires: 24 });
              alert(currentAccess);
            })
    </script>
Basically I'm trying to have currentAccess to have the current value as an integer and add and subtract as is required.
Tom
Welcome to javascript!
alert(1+1); -> 2
alert("1"+"1"); -> 11
alert(Number("1")+Number("1")); -> 2
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With