Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  48] [ 7]  / answers: 1 / hits: 57777  / 13 Years ago, thu, september 29, 2011, 12:00:00

I have the following dropdown list:



<select name=DD1 id=DD1>
<option value=B>B</option>
<option value=D>D</option>
<option value=E>E</option>
<option value=F>F</option>
<option value=R>R</option>
</select>


On page load I need to hide/delete option D. I can't go by the index because that list is dynamic so I have to use the value parameter or the actual text that gets rendered.



I've tried finding the answer but all the solutions I came across use JQuery for this and I don't have the option to do this.



Anyone have a way to hide option D just using Javascipt on page load so the user never sees that option?



Thanks


More From » html

 Answers
18
var select=document.getElementById('DD1');

for (i=0;i<select.length; i++) {
if (select.options[i].value=='D') {
select.remove(i);
}
}

[#89860] Tuesday, September 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shane

Total Points: 239
Total Questions: 91
Total Answers: 114

Location: Faroe Islands
Member since Tue, Jul 7, 2020
4 Years ago
shane questions
;