-1

here is my code:

<select id="List" name="UserType" onChange ="hide"> <option value="0" disabled="disabled" selected="selected">Tipo de Usuario</option> <option value="1" onclick="hide">Administrador</option> <option value="2" onclick="hide">Moderador</option> <option value="3" onclick="hide">Usuario Comun</option> </select> 

when i click some value (not zero) in the the drop down, i need remove the first item from this (Tipo de Usuario). Some code in javascript able to do that?

3
  • 2
    Yes, you can do that with Javascript. What did you try? Commented May 26, 2014 at 17:57
  • list.children[0].remove(); or list.options[0].remove(); or list.removeChild(list.options[0]); Commented May 26, 2014 at 18:15
  • Dalorzo i saw these post but dont work for me Commented May 26, 2014 at 21:17

2 Answers 2

0

you can always use this:

<option disabled selected style="display:none">Tipo de usuaro</option> 
Sign up to request clarification or add additional context in comments.

1 Comment

not all browsers respect hiding options via display.
0
function hide(){ var list = document.getElementById("List"); list.removeChild(list.childNodes[1]); } 

3 Comments

childNodes includes whitespace, making it dangerous to rely on...
This will remove the first item even if the selected item is value zero.
@Gabriel but according to the given html the first item cannot be selected

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.