Jump to content

selecting particular contents in dropdown list


rizwansyed

Recommended Posts

Hi

I need to get a selected data from drop down list and then use it in other tab.

For example , If i have 2 tabs and in tab 1 if i select "SI units" then in other tab only "A" should be visible and "B" should be hidden or disabled

if i select "US units" then in other tab only "B" should be visible and "A" should be hidden or disabled.

I have attached a text file for this

Please suggest 

 

Thanks In advance

accessing different tab content.txt

Link to comment
Share on other sites

Use some Javascript for it.

You'll need to change the `id` attribute for the A & B `<select>` element.

To hide an option, all you need to do is change the `.innerHTML` property of the `<select>` to not include it. This can get messy, as if that option can reappear, then it needs to be stored somewhere else when you hide it.

// On page load store an associative array of (value : innerhtml) with respect to each option

//When the first dropdown is changed (function)
//Get the corresponding values
var value_thing = "A";
var innerHTML_thing = "A";
//Change the select to only display the value(s) applicable
document.getElementById('units').innerHTML = "<option value='"+value_thing+"'>"+innerHTML_thing+"</option>";

To disable an option, all you need to do is find out which option(s) (found in the `.options` collection) needs to be disabled.

//When the other dropdown is changed (function)
//Disable the options that aren't applicable
document.getElementById('units').options[1].disabled = true;

 

Those are the meatiest bits of Javascript you will need. Everything else, you already have the logic for in your post.

(NOT TESTED SO BE SURE TO CHECK IT)

Edited by Funce
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...