Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this program that will add the value in a textbox, checkbox and dropdown menu. The way it run is, the textboxes will be added, then if the customer checks the checkbox, it will be added to the payment if not checked, no additional payment. then the drop down menu, whatever the customer will choose, it will be added to the payment.
How will I write my code to get the total of all the values?

These are my codes so far.

JavaScript
function subtotal(){
    var a = document.getElementById("sff").value;
    var b = document.getElementById("osf").value

    var stotal = a+b;
    document.getElementById("st").innerHTML = "$" + stotal;

}</pre>


HTML
<pre lang="HTML"><input type="text" id="osf" placeholder="$0.00" style="float:left;" onchange="subtotal()"/>
<input type="text" id="sff" placeholder="$0.00" style="float:left;" onchange="subtotal()"/>
<select style="margin: 3px 0 0 55px; width:48%; position: absolute; float: left; ">
                    &lt;option value="">(Select Number Of Years Of Agent Service To Purchase)&lt;/option>
                    &lt;option value="a1">1 Year @ $99.00/yr (Service to December 2015)&lt;/option>
                    &lt;option value="a2">SAVE! 2 Years (@ $89.10/yr) for only $178.20 (Service to December 2016) - Save $19.80&lt;/option>
                    &lt;option value="a3">SAVE! 3 Years (@ $80.52/yr) for only $241.56 (Service to December 2017) - Save $55.44&lt;/option>
                    &lt;option value="a4">SAVE! 4 Years (@ $73.06/yr) for only $292.24 (Service to December 2018) - Save $103.75&lt;/option>
                    &lt;option value="a4">SAVE! 5 Years (@ $66.56/yr) for only $332.80 (Service to December 2019) - Save $162.20&lt;/option>
                &lt;/select>
<input type="checkbox" id="cbx2"/>($35.00) - Prepare IRS Form SS-4 (Federal EIN Number)</pre>
Posted
Comments
ZurdoDev 7-Dec-14 22:06pm    
Where are you stuck?
mudgilsks 7-Dec-14 23:46pm    
can you explain the actual flow,what you want in code.
Azziet 8-Dec-14 2:24am    
add all the values with you flow, with checking that textbox has value, dropdown select and chechbox chceked or not....
mudgilsks 8-Dec-14 3:29am    
adding textbox value --right

next what is the role of checkbox and dropdown --Not Clear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900