I am trying to use jquery parent / siblings to search for specific input elements, but I cannot figure out what is right.
I have the following HTML:
<div id="ExtrasOptions"> <div class="selectItem"> <div class="selectPrice"><span>Qty: <input name="qty" type="text" value="0" maxlength="2" id="qty" class="AccessoryQuantity" /></span></div> <div class="selectIt"><span><input name="extraselected" type="checkbox" id="extraselected" value="9" /><label for="extrasID">Add this</label></span></div> </div> <div class="selectItem"> <div class="selectPrice"><span>Qty: <input name="qty2" type="text" value="0" maxlength="2" id="qty2" class="AccessoryQuantity" /></span></div> <div class="selectIt"><span><input name="extraselected2" type="checkbox" id="extraselected2" value="9" /><label for="extrasID">Add this</label></span></div> </div> </div>
Q1: When someone checked the box, I want the text box inside the same div.selectItem to contain "1". If they uncheck the box, I want the value to be removed.
Q2: I also want the checkbox to be checked if the value is entered in the text box and not checked if the text box is empty.
Thank you for your help.
source share