Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is my date text box

<input name="SetDueDate" type="text" id="SetDueDate" placeholder="Date" onchange="DisableTimeSlots()" style="width:44%;">


This is my time dropdown

<select name="SetTime" id="SetTime" style="width:44%;">
			<option value="1|1">09:00:00</option>
			<option value="2|1">09:15:00</option>
			<option value="3|1">09:30:00</option>
			<option value="4|1">09:45:00</option>
			<option value="5|1">10:00:00</option>
			<option value="6|1">10:15:00</option>
			<option value="7|1">10:30:00</option>
			<option value="8|1">10:45:00</option>
			<option value="9|1">11:00:00</option>
			<option value="10|1">11:15:00</option>
			<option value="11|1">11:30:00</option>
			<option value="12|1">11:45:00</option>
			<option value="13|1">12:00:00</option>
			<option value="14|1">12:15:00</option>
			<option value="15|1">12:30:00</option>
			<option value="16|1">12:45:00</option>
			<option value="17|1">13:00:00</option>
			<option value="18|1">13:15:00</option>
			<option value="19|1">13:30:00</option>
			<option value="20|1">13:45:00</option>
			<option value="21|1">14:00:00</option>
			<option value="22|1">14:15:00</option>
			<option value="23|1">14:30:00</option>
			<option value="24|1">14:45:00</option>
			<option value="25|1">15:00:00</option>
			<option value="26|1">15:15:00</option>
			<option value="27|1">15:30:00</option>
			<option value="28|1">15:45:00</option>
			<option value="29|1">16:00:00</option>
			<option value="30|1">16:15:00</option>
			<option value="31|1">16:30:00</option>
			<option value="32|1">16:45:00</option>
			<option value="33|1">17:00:00</option>
			<option value="34|1">17:15:00</option>
			<option value="35|1">17:30:00</option>
			<option value="36|1">17:45:00</option>
			<option value="37|1">18:00:00</option>
			<option value="38|1">18:15:00</option>
			<option value="39|1">18:30:00</option>
			<option value="40|1">18:45:00</option>
			<option value="41|1">19:00:00</option>
			<option value="42|1">19:15:00</option>
			<option value="43|1">19:30:00</option>
			<option value="44|1">19:45:00</option>
			<option value="45|1">20:00:00</option>
			<option value="46|1">20:15:00</option>
			<option value="47|1">20:30:00</option>
			<option value="48|1">20:45:00</option></select>


This is the calendar I am using with the text box, My function is didn't even called, please suggest how to call this function and how to read the date from the date text box.

$(function () {
                CalenderSetup('SetDueDate', 'ViewCalenderDate');
            });


            function CalenderSetup(InputTxtFieldID, InputButtonID) {
                //Please Call its Library on its specific page
                Calendar.setup({
                    inputField: '' + InputTxtFieldID + '',      // id of the input 
                    ifFormat: "%m/%d/%Y",
                    //ifFormat: "%Y-%m-%d",          // format of the input field
                    showsTime: false,            // will display a time selector
                    button: '' + InputButtonID + '',   // trigger for the calendar 
                    singleClick: true,            // Single-click mode
                    dateStatusFunc: dateStatus
                });
            }


What I have tried:

I tried this function but not working

function DisableTimeSlots() {
           var today = new Date();
           if ($("#SetDueDate").text() = today) {
               var CurrentTime = new Date($.now());
               var a = $("#SetTime").get(0);
               for (var i = 0; i < a.length; i++) {
                   var splitvalue = a[i].value.split('|')[1];
                   if (a[i] < Now) {
                       a[i].hidden = true;
                   }
               }

           }
           }
Posted
Updated 27-May-22 0:52am
v2

1 solution

Equality checking with JavaScript is done with == or ===. Your check for today's date uses =.
 
Share this answer
 
Comments
Rizwan Nazar 27-May-22 6:47am    
This function DisableTimeSlots() didn't even call, I checked through debugging in inspect.

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