Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
var apptHour = $('select[name="ctl00$m$g_29cbb5be_bcd6_4949_875d_8fad4732db9b$ctl00$ctl05$ctl09$ctl00$ctl00$ctl04$ctl00$ctl00$DateTimeField$DateTimeFieldDateHours"]');  
var endHour = $('select[name="ctl00$m$g_29cbb5be_bcd6_4949_875d_8fad4732db9b$ctl00$ctl05$ctl11$ctl00$ctl00$ctl04$ctl00$ctl00$DateTimeField$DateTimeFieldDateHours"]');

apptHour.blur(function() {
       endHour.val($(this).val());
    });

This copies the hour (when I select the Appointment Date: Hour and the End: Hour will copy it) and of course there is minute too.

but I am afraid the long name will change over time.

In javascript i can use the

var apptHour = $("label:contains('Appointment Date Hours')").next().val();
var endHour = $("label:contains('End Hours')").next().val();

for conditional expression but it won't work if i tried to copy using jQuery.

enter image description here

Is there a way to do it?

Thanks

share|improve this question
You should either use IDs that you generate to identify which objects on a page contain the variables you need to grab. Or you can figure out how sharepoint is generating those names and pass those into Javascript dynamically. – Danack 11 hours ago

migrated from stackoverflow.com 11 hours ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.