Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How to use Jquery to check checkbox states and do something based on conditions? -


here setup.

<input type="checkbox" name="item1" value="100" class="100" /> <input type="checkbox" name="item2" value="200" class="200" /> <input type="checkbox" name="item3" value="300" class="300" />  <p>$0.00</p> 

the criteria need is: change p tag amount selected in checkbox if more 1 checkbox checked, add amount , display in p tag if 1 or more checkbox unchecked, subtract amount , display in p tag if none selected or of them unchecked, display 0 in p tag.

i have far displays price of selected box , doesn't add nor remove when uncheck box.

$("input[type=checkbox]").click(function() { var amount = $(this).attr("class"); $("p").html("$"+amount); }); 

any appreciated!

simple try...

$("input[type=checkbox]").change(function() {     var amount = 0;     $("input[type=checkbox]:checked").each(function(){         amount += parsefloat(this.value,10);     });     $("p").html("$"+amount); }); 

crazy demo


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -