admin管理员组文章数量:1317909
I have a normal HTML select dropdown box
<select id="day" name="day">
<option value="0">All</option>
<option value="1">Mon</option>
<option value="2">Tue</option>
<option value="3">Wed</option>
<option value="4">Thu</option>
<option value="5">Fri</option>
</select>
But on occassion I want to make some options not clickable, e.g. the Text faded out slightly if possible, and then nothing to happen if the text/value is selected.
Anyone know how?
I'm writing my page in PHP.
I have a normal HTML select dropdown box
<select id="day" name="day">
<option value="0">All</option>
<option value="1">Mon</option>
<option value="2">Tue</option>
<option value="3">Wed</option>
<option value="4">Thu</option>
<option value="5">Fri</option>
</select>
But on occassion I want to make some options not clickable, e.g. the Text faded out slightly if possible, and then nothing to happen if the text/value is selected.
Anyone know how?
I'm writing my page in PHP.
Share Improve this question asked Dec 10, 2009 at 13:48 thegunnerthegunner 7,16334 gold badges97 silver badges144 bronze badges 2- 1 Oh. You want the options disabled, not the whole select box. I deleted my answer cause I misunderstood the question. – Vincent Ramdhanie Commented Dec 10, 2009 at 13:53
- I had previosuly written a jQuery solution for this if that's acceptable. I Don't have a pure JS fix unfortunately. – Neil Aitken Commented Dec 10, 2009 at 14:36
3 Answers
Reset to default 4Simply give the option tag an attribute 'disabled'.
<select>
<option value="1" disabled>1</option>
<option value="2">2</option>
</select>
So in this example, 1 will be faded out and un-selectable but 2 will be selectable.
IE 6 requires javascript to disable an item. There is a bug that prevents it from disabling individual items.
See here for details on how to implement this so that it functions in IE6: http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/
There is a javascript solution here
http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/
There is no way to do this in IE without a JS hack sadly.
本文标签: phpmake select box values faded outunclickableStack Overflow
版权声明:本文标题:php - make select box values faded outunclickable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742022819a2414996.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论