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 7805923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:22:04+00:00 2026-06-02T02:22:04+00:00

This is a dumb question, but im stuck. Why does my first one work

  • 0

This is a dumb question, but im stuck. Why does my first one work but not the other 3. From reading the docs, all 4 should do the job. I want to in a bigger use case get an element of a form, there could be other elements on the same page with same name inside other forms or in other divs, so the 4th option is what I really want to work. But I cant figure out why all these dont work.

http://jsfiddle.net/7vF5z/1/

html:

 <form id="filter_form_id" name="filter_form" method="get" action="/retrieved_data_records">

 <select id="brand_id" name="brands">
 <option value="0"></option>
 <option value="143272526">Brand1</option>
 <option selected="selected" value="269998788">Brand2</option>
 <option value="330516076">Brand3</option>
 <option value="330516077">Brand4</option>

 </select>
</form>

js:

 alert ("The val: " +  $('#brand_id').val() );    
 alert ("The val: " +  $('brands').val() );  
 alert ("The val: " +  $('#filter_form_id brands').val() );  
 alert ("The val: " +  $('#filter_form_id > brands').val() );  

  • 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-06-02T02:22:05+00:00Added an answer on June 2, 2026 at 2:22 am

    Your selectors use brands as if it’s an element name. You need to use an attribute selector like [name="brands"].

    Updated testcase: http://jsfiddle.net/7vF5z/3/

    alert ("The val: " +  $('#brand_id').val() );    
    alert ("The val: " +  $('[name="brands"]').val() );  
    alert ("The val: " +  $('#filter_form_id [name="brands"]').val() );  
    alert ("The val: " +  $('#filter_form_id > [name="brands"]').val() );  
    

    the 4th option is what I really want to work

    If that’s supposed to be a child selector, then you need to correct it by:

    • Using the correct child selector syntax
    • Using an attribute selector, as in my example.

    There’s no real reason to use a child selector there, unless you’re going to have multiple controls with that same name value in that same form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is really dumb question but still my head cannot work it out. I
I'm sure this is a dumb question but Googling got me nowhere. Does each
This might be a dumb question but I'm just not sure about the answer.
Possibly a dumb question but I have a number of entities all inheriting from
I think this is a dumb question but I could not find it on
This might be a dumb question...but I am trying to make my first app
This might be a dumb question but I have not find the answer when
I don't know if this is a dumb question or not but again as
Apologies if this is a dumb question but I'm trying to format a currency
So maybe this is a dumb question but do web pages look different based

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.