Thanks Aaron, I kinda figured that out when I found that things worked fine except when both checkboxes are checked and you uncheck one, my script breaks. I just wanted to use jquery to show the price of a course when its checkbox is checked. i've already solved the server side with java. I guess I have to go back to the drawing board before even writing code.
$(document).ready( function() { var total = 0; $("inp...@type=checkbox]").click(function(){ if ($(this).is(":checked")) { $("#newsletter_types").remove(); $('#newsletters').append('<span id="newsletter_types"></span>');//create span first count = $("inp...@type='checkbox']:checked").length; total = 500 * count; $('#newsletter_types').append(total + '.00'); } else $("#newsletter_types").remove(); }); }); On Sat, Feb 7, 2009 at 2:08 PM, Aaron Gundel <aaron.gun...@gmail.com> wrote: > > Bob, > > Not sure exactly what you're trying to do here. You might wish to > elaborate more. However, I can already tell you that you're going to > have issues with putting out multiple spans with the same id. You > should use a class or some other attribute to store the identification > information. > > Aaron > > On Fri, Feb 6, 2009 at 5:50 PM, coworkerbob <tribe...@gmail.com> wrote: > > > > Hi all, having trouble getting each checkbox selected to display a > > text element. > > > > This works below, but of course i want it for all checkboxes and not > > just one > > > > $(document).ready(function() > > { > > var total = 0; > > var a = 0; > > > > //morning is the name of one the checkboxes > > > > $("inp...@name=morning]").click(function(){ > > if ($(this).is(":checked")) //if check assign value and append to > > span, else uncheck remove > > { > > > > $('#newsletters').append('<span id="newsletter_types"></span>');// > > create span > > var a = 500; > > total = a; > > $('#newsletter_types').append(total + '.00'); > > } > > else > > $("#newsletter_types").remove(); > > > > }); > > }); > > > > This isn't working for me. > > > > $(document).ready(function() > > { > > var total = 0; > > > > $("inp...@type=checkbox]:checked").each(function(){ // read that > > each is like for loop > > > > count = $("inp...@type='checkbox']:checked").length; //get > > how many checked > > > > total = count * 500; > > > > $('#newsletters').append('<span id="newsletter_types"></ > > span>'); //create span > > $('#newsletter_types').append(total + '.00'); > > > > }): > > > > }); > > > > Any hints is greatly appreciated. Thanks! > > >