0

we have two dropdown lists in our MOSS portal. I want to remove second item of second dropdown list on 'Page Load', not after selecting it . I tried using javascript but as i am a beginner at scripting so it is not working . So guys is there anyway i can remove that item using css .

The dropdownlist is in a user control (ascx) file . the dropdownlist id is 'drprequest' . can we do it like :

drprequest:nth-of-child(2){display:none};

because i googled something similar to this one but i couldnt find anything.

If not can anyone give me the script to remove that item. Please help me friends .

  • is my given solution works for you? – Hardik Aug 11 '16 at 12:23
1

You can try below CSS code to hide second option from the dropdown with ID drprequest

#drprequest select:nth-child(2) {
    display:none;
}

It will hide the second child of the dropdown using the CSS.

If you want to hide any other option from dropdown than just change the number accordingly.

  • Is above solution works for you? – Hardik Aug 10 '16 at 12:42
0

Do you populate dropdown in your ascx.cs file? Try to process data on server-side.

Javascript

Remove option by its position in select:

$("[id$='drprequest'] option:eq(1)").remove()

Remove option by its value:

$("[id$='drprequest'] option[value='{option_val}']").remove()

CSS

[id$='drprequest'] select:nth-child(2) {
    display:none;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.