Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Guys please help me out,

I want to know how to enable or disable DropDown elements:
example:
XML
<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>

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.
Posted
Updated 19-Mar-11 19:15pm
v3
Comments
sabby006 20-Mar-11 11:21am    
hey thanx alben for reply but ..can you please give me the html code for this also.. and i basically want to compare current time with select time and disable or give an alert box .

1 solution

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

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


Note: optionIndex starts from 0
 
Share this answer
 
v2
Comments
sabby006 20-Mar-11 11:21am    
hey thanx alben for reply but ..can you please give me the html code for this also.. and i basically want to compare current time with select time and disable or give an alert box .
Sergey Alexandrovich Kryukov 20-Mar-11 21:59pm    
This is your work. How come you don't want to write HTML yourself?
--SA
Sergey Alexandrovich Kryukov 20-Mar-11 21:59pm    
My 5.
--SA
Albin Abel 20-Mar-11 23:02pm    
Thanks. SAKryukov. Yesterday I was reading your trick about the queued thread. It is nice and I think you can post it as an article with some source codes. Because when you give that as a reference to beginners questions here, it may be little difficult for them to understand conceptually without a source code. What you think?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900