如何使用JavaScript启用或禁用下拉元素(值)... [英] how to enable or disable dropdown elements(values)...using javascript

查看:78
本文介绍了如何使用JavaScript启用或禁用下拉元素(值)...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们请帮帮我,

我想知道如何启用或禁用DropDown元素:
例如:

Guys please help me out,

I want to know how to enable or disable DropDown elements:
example:

<select name="time_select">
<option>10:00AM</option>
<option>1:30</option>
<option>5:00PM</option>
<option>7:30PM</option>
<option>10:00PM</option>
</select>


在这里,我想从浏览器检查时间,并且时间是否大于选项中的值应该禁用特定值. 应禁用特定值 .

thanx 谢谢.


here i want to check the time from the browser and if the time is greater than the value in the option than THAT PARTICULAR VALUE SHOULD BE DISABLED. that particular value should be disabled.

thanxThanks.

推荐答案

您的问题是关于如何比较时间或如何禁用选项的.如果知道比较时间的逻辑,则将这些列表与当前时间进行比较,找到要禁用的选项,然后就可以这样使用

Your question is about how to compare time or how to disable an option?. If know the logic to compare the time then compare those list with the current time find which option to disable then you can use like this

function optionDisable(selectId, optionIndex){
    document.getElementById(selectId).children[optionIndex].disabled="disabled";
}



注意:optionIndex从0开始



Note: optionIndex starts from 0


这篇关于如何使用JavaScript启用或禁用下拉元素(值)...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆