Clear Select Based on Uncheck using Javascript -
using jsfiddle this question able see how can clear input box form check box. question how alter javascript clear select (in case 'addbasepfo14') instead specific name instead of clearing input found in form without disrupting existing onchange event?
$(document).ready(function(){ $('#chk').live('change',function(){ if(!$(this).is(':checked')) $('input').val(''); }); }); <form> <input type="checkbox" id="chk"> <select id="addbasepfo14" name="addbasepfo14" onchange="calculatetotal()" /> <option value="0">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </form>
you can do:
$("#chk").change(function() { if (this.checked) $("#addbasepfo14").val(0) //assuming option value of 0 default });
you have 2 checkboxes id of chk
, id's must unique!
Comments
Post a Comment