brainybabe12
New Member
I am making my first foray into javascript + jQuery, designing a simple page but encountering errors, I'm sure it's something silly but I've been over the code several times and can't spot it.The error I receive is below:
The entire code is below (I've changed the dynamic \[code\]'#' + elementname + 'perc'\[/code\] to a string and I get the same error), can anyone offer any insight?\[code\]<DOCTYPE html><html> <head> <script src="http://stackoverflow.com/questions/15657717/js/jquery.js"></script> <!--<script src="http://stackoverflow.com/questions/15657717/js/dealercalc.js"></script>--> <script type="text/javascript">$(document).ready(function(){ $(".val-adjust").click(function(){ var name = $(this).attr('name'); var bit = $(this).attr('value'); setvalue(name,bit); //discountbits['basic'] = false; //$("#basedisper").text(discountlist['basic']); }); $("#basdisyes").click(function(){ discountbits['basic'] = true; //$("#test1").html("<b>Hello world!</b>"); }); $("#btn3").click(function(){ $("#test3").val(gettotal()); });});function getpercbypurc(value){ return 0;};function setvalue(elementname,yesno){ discountbits[elementname] = yesno; if (yesno) { $("#basicperc").hmtl(discountlist[elementname] + "%"); } else { $('#' + elementname + 'perc').hmtl("0%"); }};function gettotal() { var total = 0; for (var i=0; i<keys.length; i++){ if (discountbits[keys] = true) { total += discountlist[keys]; } } return total;};function displaytotal(){ $('#totalper').html(gettotal());};var keys = ['basic', 'marketing'];var discountlist = { basic:20, marketing:2};var discountbits = { basic:true, marketing:false}; </script> </head> <body> Base Discount<br> <button class="val-adjust" name="basic" value="http://stackoverflow.com/questions/15657717/false">No</button> <button class="val-adjust" name="basic" value="http://stackoverflow.com/questions/15657717/true">Yes</button> <span id="basicperc">0</span> <br> <br> Marketing Plan<br> <button class="val-adjust" name="marketing" value="http://stackoverflow.com/questions/15657717/false">No</button> <button class="val-adjust" name="marketing" value="http://stackoverflow.com/questions/15657717/true">Yes</button> <span id="marketingperc">0</span> <br> <br> Total<br> <span id="totalper">0</span> </body></html>\[/code\]