0

I tried this code to disable the options in the drop-down in the date picker time:

Script editor:

enter image description here

the value is still visible.

enter image description here

But it is not working.

Kindly advise.

enter image description here enter image description here

0

Try something like below:

<script>
    $(document).ready(function() {
        $("#selectId").children("option[value='00']").hide();
    });
</script>

Where #selectID will be ID of your select control (Add selector carefully to get the particular element only).

Update:

For your case try this:

$("#Time_x0020_Slot_x0020_Date_b6585aee-0ec0-4964-a13b-67eec8d23e75_$DateTimeFieldDateHours").children("option[value='0']").hide();

If you want to remove the option then you need to use this:

$("#Time_x0020_Slot_x0020_Date_b6585aee-0ec0-4964-a13b-67eec8d23e75_$DateTimeFieldDateHours").children("option[value='0']").remove();

Note: Remember, this select element is for Hours drop-down and its option values are like 0, 1, 2... and so on.

  • Hi, I tried your code, but still is not working. Kindly refer to the screenshots above. This is the html code for that element : <select id="Time_x0020_Slot_x0020_Date_b6585aee-0ec0-4964-a13b-67eec8d23e75_$DateTimeFieldDateHours"><option value="0">00:</option><option value="1">01:</option><option value="2">02:</option><option value="3">03:</option><option value="4">04:</option><option value="5">05:</option><option value="6">06:</option><option value="7">07:</option></select> – sangasangasanga Jul 25 '19 at 8:54
  • 1
    Use selector as $("#selectID"). you are missing # in your selector. – Ganesh Sanap Jul 25 '19 at 8:55
  • 1
    See updated answer. This is for hours dropdown and not for minutes dropdown. – Ganesh Sanap Jul 25 '19 at 8:58
  • 1
    Is there any error in browser's console? – Ganesh Sanap Jul 25 '19 at 9:08
  • 1
    Try adding debugger, I guess you are not getting the right select dropdown using the selector. – Ganesh Sanap Jul 25 '19 at 9:19
0

Refer below code: This is example to disable first value(0th position) in dropdown.

Here "DT" in the jQuery selector($("input[title='DT']")) is the "title" of DateTime field. (Update this with the title of you field). No Need to update anything else. It should work.

var tdTimeSection = $("input[title='DT']").closest("td").siblings(".ms-dttimeinput");
$(tdTimeSection).find("select:eq(0)").find("option[value='0']").attr('disabled','disabled');

enter image description here

  • I tried like you said (changed the DT)but I still see the value. What am i doing wrong? – sangasangasanga Jul 30 '19 at 3:24
  • Are you getting any error in console? If yes, please share the details – Rohit Waghela Jul 30 '19 at 8:33
  • There is no errors in the console. I used console logs front n back to verify the code ran. But the value is still visible – sangasangasanga Jul 30 '19 at 9:15
0

Maybe I am just ignorant, but why not just change the Time Slot Date column to only be a Date Field and not a Date and Time field?

Maybe try this if you must use jQuery:

$("select[id*='Time']").hide();

If that wont work - you may have better luck by putting the script in a .html file and store it on the site and refer to it with a content editor web part. Sometimes the Snippets do funny things.

  • I need the item too, but only certain values – sangasangasanga Jul 30 '19 at 6:22
  • The original post needs to be a little bit more specific then, what exactly are you trying to accomplish here? – SP-Kyle Jul 31 '19 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.