Javascript for : Start Manual Publishing Date Default setting

<!-- Start Manual Publishing Date Default setting -->
					<script type="text/javascript">
						setDefaultDate(); 
						setRequestEndTime('ctl00_PlaceHolderMain_ctl07_ctl00_DateTimeField_DateTimeFieldDateHours','ctl00_PlaceHolderMain_ctl07_ctl00_DateTimeField_DateTimeFieldDateMinutes')
						// Set the Request End Time to today's date
						function setDefaultDate() 
						{
							today = new Date();
							todayDay = today.getDate();
							todayMon = today.getMonth() + 1;
							todayYear = today.getYear();
							var tags = getElementByTitle('INPUT','Manual Publish Date');
							tags.value = todayMon + "/" + todayDay + "/" + todayYear;
						}
						function getElementByTitle(tagName,elementTitle)
						{
							var elementTag;
							var els = document.getElementsByTagName(tagName);
							var elsLen = els.length;
							var pattern = new RegExp("(^|\\s)" + elementTitle + "(\\s|$)");

							for (i = 0, j = 0; i < elsLen; i++) {
									if (elementTitle.toUpperCase()==els[i].title.toUpperCase()) 
									{
										elementTag= els[i];
									   j++;
									}
								}
								return elementTag;
						}
						// Set the Request End Time to '11 PM'
						function setRequestEndTime(cntlNameHrs,cntlNameMin) {
							var d = new Date();
							var preAM=" AM";
							var prePM=" PM";
							var curr_hour = d.getHours();
							var curr_min = d.getMinutes();
							if(curr_hour<13)
							{
								curr_hour= curr_hour+preAM;
							}
							else
							{
								curr_hour= (curr_hour-12)+prePM;
							}

							curr_min=curr_min-(curr_min%5);

							var tags = document.getElementsByTagName('select');
							for (var i=0; i < tags.length; i++) {
								//alert(' tags[' + i + '].id=' + tags[i].id);
								if(tags[i].id == cntlNameHrs) {
									//alert('HIT tags[' + i + '].id=' + tags[i].id);
									innerspans = tags[i].getElementsByTagName('option');
									//alert(innerspans.length);
									for (var j=0; j < innerspans.length; j++) {
										//alert('innerspans[' + j + '].value=' + innerspans[j].value);
										if (innerspans[j].value == curr_hour) {
											innerspans[j].selected = true;
											break;
										}
									}
								}
								if(tags[i].id == cntlNameMin) {
									//alert('HIT tags[' + i + '].id=' + tags[i].id);
									innerspans = tags[i].getElementsByTagName('option');
									//alert(innerspans.length);
									for (var j=0; j < innerspans.length; j++) {
										//alert('innerspans[' + j + '].value=' + innerspans[j].value);
										if (innerspans[j].value == curr_min) {
											innerspans[j].selected = true;
											break;
										}
									}
								}
							}
						}

					</script>
					<!-- End Manual Publishing Date Default setting -->
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s