We're scheduling a lot of similar events, so the start time is almost always 8:30AM and the end time is almost always 5:30PM (not necessarily on the same day). Is there any way that we can set the defaults for these through JavaScript? It doesn't necessarily have to be JS, we just can't use workflows to solve this problem because we do occasionally have events that need to happen at other times. A solution editing the NewForm.aspx would work as well if anyone has that. OOTB would be even better.

It looks like this (http://blog.pentalogic.net/2009/09/setting-default-duration-for-new-calender-events/) was written for SP2010. I used Firebug to inspect the labels for my time fields. They aren't actually "label" tags, they are "nobr" tags and do not have "for" attributes, so it appears that this solution is trying to access elements that SharePoint is no longer using.

I would just use the ID columns of the time boxes themselves, but they are some kind of generated code and and I'm worried that they won't always be the same. I have shown the generated code for the Start Time select box:

<select id="ctl00_ctl41_g_05eee1e1_a7d0_4b5e_9eb1_dc1e566ce47e_ctl00_ctl05_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDateHours" dir="ltr" name="ctl00$ctl41$g_05eee1e1_a7d0_4b5e_9eb1_dc1e566ce47e$ctl00$ctl05$ctl00$ctl00$ctl00$ctl04$ctl00$ctl00$DateTimeField$DateTimeFieldDateHours">
    <option value="12 AM">12 AM</option>
    <option value="1 AM">1 AM</option>
    <option value="2 AM">2 AM</option>
    <option value="11 AM">11 AM</option>
    <option value="12 PM" selected="selected">12 PM</option>
    <option value="1 PM">1 PM</option>
    <option value="10 PM">10 PM</option>
    <option value="11 PM">11 PM</option>

I need a way to set this that will always work and I suppose that if we know that the ID will always be the horrendously long string shown above, then I can just hard code that and get the element by its ID, but I don't know if it will be. Any advice?

Also, if it is important, I am using the modal window (and need to continue to do so).

EDIT: This question was flagged as a duplicate. In order to argue why this should not be the case, I would like to first point out, that the link I referenced above, is the same link as the answer to the question this one was claimed to be a duplicate of. Furthermore, I covered why I don't believe the solutions work. Yes, it is essentially the same goal, but the previous question was in the context of SharePoint 2010 and this one is in the context of SharePoint 2013 and I believe that makes them different because the answers for SharePoint 2010 don't appear to work for 2013. Also, the answers to the other question specifically exclude modal dialogues which are required in this question.

Your Answer

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

Browse other questions tagged or ask your own question.