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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:54:55+00:00 2026-05-29T10:54:55+00:00

i need a little bit of help with some jquery thing that i’m sure

  • 0

i need a little bit of help with some jquery thing that i’m sure is stupid but has got me stuck. in the first dropdown is a list of products. in the second is a list of content associated with the products. i need to show/hide the corrent contents in the second dropdown according to what is selected in the first.

for example: if i select “FOO” in the first list, with value 1213, i need to select values 1213-3973 and 1213-3953 from the second list. the values in both menus are obviously dynamic, but will always have the format given, ie: the value in contentselect options will always be {product_id}-{content_id}

at first, being not super-knowledgeable about html, i had a custom attribute set in the contentselect form which i had my jquery selector grab. however, it appears that not all browsers like custom attributes.

as it is now, i’m not exactly sure what to do. i was told i would need some kind of regex, but i’m not sure where to start with that.

<script>
function selectProduct()
{
    //reset form
    $('.form_contentselect option:selected').removeAttr("selected");

    var product_selected = $('.form_productselect option:selected').val();
    $('.form_contentselect').hide();
    /////////HELP HERE PLEASE//////////
    //$('.form_contentselect option[???????????]').hide(); //HIDE irrelevant content
    //$('.form_contentselect option[???????????]').show();  //SHOW associated content
    ///////////////////////////////////
    $('.form_contentselect').show();

}
</script>

<div class="form_productselect">
    <div class="form_item"> 
        Select Product: 
        <select name="product_id" onchange=selectProduct()>
            <option value="0" selected="selected">--</option>
            <option value="1213" >FOO</option>
            <option value="1315" >BAR</option>
        </select>
    </div>
</div>

<div class="form_contentselect">
    <div class="form_item"> 
        Select Content: 
        <select name="content_id">
            <option value="0" selected="selected">--</option>
            <option value="1213-3973" >FOO - 100 points</option>
            <option value="1213-3953" >FOO - 1000 points</option>
            <option value="1315-3965" >BAR - 100 points</option>
            <option value="1315-3949" >BAR - 1000 points</option>
        </select>
    </div>
</div>
  • 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-29T10:54:56+00:00Added an answer on May 29, 2026 at 10:54 am

    Unfortunately hiding or disabling options in a select in not supported cross browser. See this question.

    I think your best option would be something similar to this answer from the linked question above.

    Here is a working demo that is supported cross browser

    html:

    <div class="form_productselect">
        <div class="form_item">
            Select Product:
            <select id="product_id" name="product_id">
                <option value="0" selected="selected">--</option>
                <option value="1213" >FOO</option>
                <option value="1315" >BAR</option>
            </select>
        </div>
    </div>
    
    <div class="form_contentselect">
        <div class="form_item">
            Select Content:
            <select id="content_id" name="content_id">
                <option value="0" selected="selected">--</option>
                <option value="1213-3973" class="opt-1213" >FOO - 100 points</option>
                <option value="1213-3953" class="opt-1213" >FOO - 1000 points</option>
                <option value="1315-3965" class="opt-1315" >BAR - 100 points</option>
                <option value="1315-3949" class="opt-1315" >BAR - 1000 points</option>
            </select>
        </div>
    </div>
    

    jquery:

    $(document).ready(function() {
        var allOptions = $('#content_id option').clone();
        $('#product_id').change(function() {
            var val = $(this).val();
            $('#content_id').html(allOptions.filter('.opt-' + val));
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a SQL noob, and I need a little bit of help understanding the
Just need a little bit of Javascript to warn people that press the back
Maybe this sounds a little bit crazy, but I need to come up with
Need a little help with my jquery here I want all my button with
I need a little bit of help disciplining my HTML. It seems to be
I have a friend that has a little bit of a holiday coming up
I need little bit help related to android tabhost. I have 3 tabs and
I need a little bit help regarding to android socket programming. I had made
still trying to figure out jQuery and I need some help with a sidebar
I need to print some data (a little bit strange formatted). I was writing

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.