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

  • Home
  • SEARCH
  • 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 9040019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:52:46+00:00 2026-06-16T09:52:46+00:00

I am having 2 select box, code below. Parent Selectbox <select name=user_type id=user_type> <option

  • 0

I am having 2 select box, code below.

Parent Selectbox

<select name="user_type" id="user_type">
    <option value="">Please Choose An Option</option>
    <option value="PRIVATE OWNER">PRIVATE OWNER</option>
    <option value="TRADER">TRADER</option>
</select>

Child Selectbox

<select name="package_type" id="package_type">
    <option value="">Please Choose An Option</option>
    <option value="SINGLE ENTRY">SINGLE ENTRY</option>
    <option value="FEATURED ENTRY">FEATURED ENTRY</option>
    <option value="STANDARD">STANDARD</option>
    <option value="ULTIMATE">ULTIMATE</option>
</select>

I want if private owner is selected from the parent selectbox then only SINGLE ENTRY and FEATURED ENTRY SHOULD SHOW UP and rest of them are removed or deleted using jquery.

I dont have any clue about how to achieve this.

Below is my jquery code, it doesnt include the code for the logic about what I am asking as I have no idea how to dynamically add or remove tags.

Also please exclude the php part in below code as it my own logic to fetch the values from session and database and provide them to jquery variables etc.

Please let me know how can I achieve this thing.

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
<?php
// Pre Populate User From Session
$user_type = $session->getSession("packages_user_type");
if ($user_type != "TRADER")
{
?>
    $('#package_type_container, #slots_container, #notes_ultimate').hide();
<?
}
?>
    $('#user_type').change(function()
    {
        var user_type = $(this).val();
        if(user_type == "TRADER")
        {
            $('#package_type_container').slideDown().show();
            $('#slots_container').slideDown().show();
        }
        else
        {
            $("#package_type").find("option:selected").removeAttr('selected');
            $('#package_type_container').slideUp();
            $('#slots_container').slideUp();
        }
    });

    $('#package_type').change(function()
    {
        var package_type = $(this).val();
        if(package_type == "SINGLE ENTRY")
        {
            $('#slots').val('1').attr('readonly', true);
            $('#cost').val('').removeAttr('readonly');
        }
        else if(package_type == "FEATURED ENTRY")
        {
            $('#slots').val('1').attr('readonly', true);
            $('#cost').val('').removeAttr('readonly');
        }
        else if (package_type == "ULTIMATE")
        {
            $('#notes_ultimate').slideDown().show();
            $('#slots').val('').removeAttr('readonly');
            $('#cost').val('0').attr('readonly', true);
        }
        else
        {
            $('#notes_ultimate').hide();
            $('#slots').val('').removeAttr('readonly');
            $('#cost').val('').removeAttr('readonly');
        }
    });
});
</script>
  • 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-16T09:52:47+00:00Added an answer on June 16, 2026 at 9:52 am

    You can do something like this using .detach() to remove the options then appending the relevant options afterwards

    var $popts = $('#package_type option'); // store all available options
    var sel = {
        "default": $popts.eq(0), 
        "PRIVATE OWNER": $popts.slice(1,3), // available values for PRIVATE OWNER
        "TRADER": $popts.slice(1) // available values for TRADER
    };
    
    $('#user_type').change(function(){
        // detach all options
        $('#package_type option').detach();
        // if value is '' then append the default - else append the correct options
        $('#package_type').append(this.value == '' ? sel['default'] : sel[this.value]);    
    });​
    

    FIDDLE

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

Sidebar

Related Questions

I am having the below code for population the select box dynamically.THis works fine
jsscriptfile cssfile I am having problems sending the value from the select box name
I wanted to do the following: Having a select box, <select name=some id=some> <option
I'm having difficulty changing the value of select box in Zurb's foundation. I'm using
I'm having difficulty with using jQuery to reset a value of a select box.
The below code having a selectbox with id='theservice' and a text field with id
I am having problems with the following code: I have n numbers of select
Having a problem with dynamically populated select boxes using jQuery. Basically, my code calls
I'm having a (probably super simple) issue. The code below is supposed to _POST
i'm trying to get jquery to add the value of a select box to

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.