Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 341089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:40:37+00:00 2026-05-12T10:40:37+00:00

I am trying to use jquery’s parents/siblings to find particular input elements but I

  • 0

I am trying to use jquery’s parents/siblings to find particular input elements but I cannot seem to get this 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 a checkbox I want the textbox within the same div.selectItem to have a ‘1’ put into it. If they uncheck the checkbox I want the value to be removed.

Q2: I also want the checkbox to be checked if a value is entered into the textbox and unchecked if the textbox is blank.

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:40:37+00:00Added an answer on May 12, 2026 at 10:40 am

    Something like this should work. (Not tested for precise syntax, but the algorithm is solid.)

    // Bind an event to each of your checkboxes, for when they are clicked
    $("input[type=checkbox]").click(function() {
      if ($(this).attr("checked")) {
        // The checkbox is checked, so find the associated text input and change its value
        $(this).parents(".selectItem").find("input[type=text]").val("1");
      } else {
        // The checkbox is unchecked, so find the associated text input and remove its value
        $(this).parents(".selectItem").find("input[type=text]").val("");
      }
    });
    
    // Bind an event to each of your text inputs, for when they have text entered into them
    $("input[type=text]").keypress(function() {
      if ($(this).val() != "")) {
        // There is something in the text input box, so check the associated checkbox
        $(this).parents(".selectItem").find("input[type=checkbox]").attr("checked","checked");
      } else {
        // There is nothing in the text input box, so uncheck the associated checkbox
        $(this).parents(".selectItem").find("input[type=checkbox]").attr("checked","");
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery with the Validate plugin, except I cannot get my
I'm trying to use jquery load function, but I can't get the whole content
I'm trying to use jQuery.post() function to retrieve some data. But i get no
I am need paint my image. I'm trying use JQuery in here this link:
I am trying to use jQuery's draggable and sortable to sort elements listed inside
I am trying to use jQuery autocomplete on my dynamically created textboxes. this is
I'm trying to use jquery to submit my form like so but it's not
Trying to use JQuery Easing plugin in my wordpress but its giving me following
im trying to use jquery bbq for remembering page with ajax. but i wonder,
i'm trying to use jquery to append an element to two places, but only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.