Jump to content

it9888

Members
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

0 Neutral

About it9888

  • Rank
    Newbie
  1. it9888

    Date picker

    Hi everyone,I'm using some script that i found on the internet. It's a Date picker, really good, but i need one small addition to it. I'm not familiar with javascript, so i cannot do it myself. Basically, what i have here is a booking engine. The user selects the "starting date"and what i want is that the "ending date" automatically changes to a week later from the starting date. Here's the code: /*********************************************** Fool-Proof Date Input Script with DHTML Calendar by Jason Moon - webmaster@moonfam.net ************************************************/// Customizable variablesvar DefaultDateFormat = 'MM/DD/YYYY'; // If no date format is supplied, this will be used insteadvar HideWait = 3; // Number of seconds before the calendar will disappearvar Y2kPivotPoint = 76; // 2-digit years before this point will be created in the 21st centuryvar FontSize = 11; // In pixelsvar FontFamily = 'Tahoma';var CellWidth = 18;var CellHeight = 16;var ImageURL = 'images/calendar.gif';var NextURL = 'images/next.gif';var PrevURL = 'images/prev.gif';var CalBGColor = 'white';var TopRowBGColor = 'buttonface';var DayBGColor = 'lightgrey';// Global variablesvar ZCounter = 100;var Today = new Date();var WeekDays = new Array('S','M','T','W','T','F','S');var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);var MonthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');// Write out the stylesheet definition for the calendarwith (document) { writeln('<style>'); writeln('td.calendarDateInput {letter-spacing:normal;line-height:normal;font-family:' + FontFamily + ',Sans-Serif;font-size:' + FontSize + 'px;}'); writeln('select.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}'); writeln('input.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}'); writeln('</style>');}// Only allows certain keys to be used in the date fieldfunction NumOnly(e) { var KeyCode = (e.keyCode) ? e.keyCode : e.which; return ((KeyCode == 8) // backspace || (KeyCode == 9) // tab || (KeyCode == 37) // left arrow || (KeyCode == 39) // right arrow || (KeyCode == 46) // delete || ((KeyCode > 47) && (KeyCode < 58)) // 0 - 9 );}// Gets the absolute pixel position of the supplied elementfunction GetTagPixels(StartTag, Direction) { var PixelAmt = (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop; while ((StartTag.tagName != 'BODY') && (StartTag.tagName != 'HTML')) { StartTag = StartTag.offsetParent; PixelAmt += (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop; } return PixelAmt;}// Is the specified select-list behind the calendar?function BehindCal(SelectList, CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY) { var ListLeftX = GetTagPixels(SelectList, 'LEFT'); var ListRightX = ListLeftX + SelectList.offsetWidth; var ListBottomY = ListTopY + SelectList.offsetHeight; return (((ListTopY < CalBottomY) && (ListBottomY > CalTopY)) && ((ListLeftX < CalRightX) && (ListRightX > CalLeftX)));}// For IE, hides any select-lists that are behind the calendarfunction FixSelectLists(Over) { if (navigator.appName == 'Microsoft Internet Explorer') { var CalDiv = this.getCalendar(); var CalLeftX = CalDiv.offsetLeft; var CalRightX = CalLeftX + CalDiv.offsetWidth; var CalTopY = CalDiv.offsetTop; var CalBottomY = CalTopY + (CellHeight * 9); var FoundCalInput = false; formLoop : for (var j=this.formNumber;j<document.forms.length;j++) { for (var i=0;i<document.forms[j].elements.length;i++) { if (typeof document.forms[j].elements[i].type == 'string') { if ((document.forms[j].elements[i].type == 'hidden') && (document.forms[j].elements[i].name == this.hiddenFieldName)) { FoundCalInput = true; i += 3; // 3 elements between the 1st hidden field and the last year input field } if (FoundCalInput) { if (document.forms[j].elements[i].type.substr(0,6) == 'select') { ListTopY = GetTagPixels(document.forms[j].elements[i], 'TOP'); if (ListTopY < CalBottomY) { if (BehindCal(document.forms[j].elements[i], CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY)) { document.forms[j].elements[i].style.visibility = (Over) ? 'hidden' : 'visible'; } } else break formLoop; } } } } } }}// Displays a message in the status bar when hovering over the calendar daysfunction DayCellHover(Cell, Over, Color, HoveredDay) { Cell.style.backgroundColor = (Over) ? DayBGColor : Color; if (Over) { if ((this.yearValue == Today.getFullYear()) && (this.monthIndex == Today.getMonth()) && (HoveredDay == Today.getDate())) self.status = 'Click to select today'; else { var Suffix = HoveredDay.toString(); switch (Suffix.substr(Suffix.length - 1, 1)) { case '1' : Suffix += (HoveredDay == 11) ? 'th' : 'st'; break; case '2' : Suffix += (HoveredDay == 12) ? 'th' : 'nd'; break; case '3' : Suffix += (HoveredDay == 13) ? 'th' : 'rd'; break; default : Suffix += 'th'; break; } self.status = 'Click to select ' + this.monthName + ' ' + Suffix; } } else self.status = ''; return true;}// Sets the form elements after a day has been picked from the calendarfunction PickDisplayDay(ClickedDay) { this.show(); var MonthList = this.getMonthList(); var DayList = this.getDayList(); var YearField = this.getYearField(); FixDayList(DayList, GetDayCount(this.displayed.yearValue, this.displayed.monthIndex)); // Select the month and day in the lists for (var i=0;i<MonthList.length;i++) { if (MonthList.options[i].value == this.displayed.monthIndex) MonthList.options[i].selected = true; } for (var j=1;j<=DayList.length;j++) { if (j == ClickedDay) DayList.options[j-1].selected = true; } this.setPicked(this.displayed.yearValue, this.displayed.monthIndex, ClickedDay); // Change the year, if necessary YearField.value = this.picked.yearPad; YearField.defaultValue = YearField.value;}// Builds the HTML for the calendar daysfunction BuildCalendarDays() { var Rows = 5; if (((this.displayed.dayCount == 31) && (this.displayed.firstDay > 4)) || ((this.displayed.dayCount == 30) && (this.displayed.firstDay == 6))) Rows = 6; else if ((this.displayed.dayCount == 28) && (this.displayed.firstDay == 0)) Rows = 4; var HTML = '<table width="' + (CellWidth * 7) + '" cellspacing="0" cellpadding="1" style="cursor:default">'; for (var j=0;j<Rows;j++) { HTML += '<tr>'; for (var i=1;i<=7;i++) { Day = (j * 7) + (i - this.displayed.firstDay); if ((Day >= 1) && (Day <= this.displayed.dayCount)) { if ((this.displayed.yearValue == this.picked.yearValue) && (this.displayed.monthIndex == this.picked.monthIndex) && (Day == this.picked.day)) { TextStyle = 'color:white;font-weight:bold;' BackColor = DayBGColor; } else { TextStyle = 'color:black;' BackColor = CalBGColor; } if ((this.displayed.yearValue == Today.getFullYear()) && (this.displayed.monthIndex == Today.getMonth()) && (Day == Today.getDate())) TextStyle += 'border:1px solid darkred;padding:0px;'; HTML += '<td align="center" class="calendarDateInput" style="cursor:default;height:' + CellHeight + ';width:' + CellWidth + ';' + TextStyle + ';background-color:' + BackColor + '" onClick="' + this.objName + '.pickDay(' + Day + ')" onMouseOver="return ' + this.objName + '.displayed.dayHover(this,true,\'' + BackColor + '\',' + Day + ')" onMouseOut="return ' + this.objName + '.displayed.dayHover(this,false,\'' + BackColor + '\')">' + Day + '</td>'; } else HTML += '<td class="calendarDateInput" style="height:' + CellHeight + '"> </td>'; } HTML += '</tr>'; } return HTML += '</table>';}// Determines which century to use (20th or 21st) when dealing with 2-digit yearsfunction GetGoodYear(YearDigits) { if (YearDigits.length == 4) return YearDigits; else { var Millennium = (YearDigits < Y2kPivotPoint) ? 2000 : 1900; return Millennium + parseInt(YearDigits,10); }}// Returns the number of days in a month (handles leap-years)function GetDayCount(SomeYear, SomeMonth) { return ((SomeMonth == 1) && ((SomeYear % 400 == 0) || ((SomeYear % 4 == 0) && (SomeYear % 100 != 0)))) ? 29 : MonthDays[SomeMonth];}// Highlights the buttonsfunction VirtualButton(Cell, ButtonDown) { if (ButtonDown) { Cell.style.borderLeft = 'buttonshadow 1px solid'; Cell.style.borderTop = 'buttonshadow 1px solid'; Cell.style.borderBottom = 'buttonhighlight 1px solid'; Cell.style.borderRight = 'buttonhighlight 1px solid'; } else { Cell.style.borderLeft = 'buttonhighlight 1px solid'; Cell.style.borderTop = 'buttonhighlight 1px solid'; Cell.style.borderBottom = 'buttonshadow 1px solid'; Cell.style.borderRight = 'buttonshadow 1px solid'; }}// Mouse-over for the previous/next month buttonsfunction NeighborHover(Cell, Over, DateObj) { if (Over) { VirtualButton(Cell, false); self.status = 'Click to view ' + DateObj.fullName; } else { Cell.style.border = 'buttonface 1px solid'; self.status = ''; } return true;}// Adds/removes days from the day list, depending on the month/yearfunction FixDayList(DayList, NewDays) { var DayPick = DayList.selectedIndex + 1; if (NewDays != DayList.length) { var OldSize = DayList.length; for (var k=Math.min(NewDays,OldSize);k<Math.max(NewDays,OldSize);k++) { (k >= NewDays) ? DayList.options[NewDays] = null : DayList.options[k] = new Option(k+1, k+1); } DayPick = Math.min(DayPick, NewDays); DayList.options[DayPick-1].selected = true; } return DayPick;}// Resets the year to its previous valid value when something invalid is enteredfunction FixYearInput(YearField) { var YearRE = new RegExp('\\d{' + YearField.defaultValue.length + '}'); if (!YearRE.test(YearField.value)) YearField.value = YearField.defaultValue;}// Displays a message in the status bar when hovering over the calendar iconfunction CalIconHover(Over) { var Message = (this.isShowing()) ? 'hide' : 'show'; self.status = (Over) ? 'Click to ' + Message + ' the calendar' : ''; return true;}// Starts the timer over from scratchfunction CalTimerReset() { eval('clearTimeout(' + this.timerID + ')'); eval(this.timerID + '=setTimeout(\'' + this.objName + '.show()\',' + (HideWait * 1000) + ')');}// The timer for the calendarfunction DoTimer(CancelTimer) { if (CancelTimer) eval('clearTimeout(' + this.timerID + ')'); else { eval(this.timerID + '=null'); this.resetTimer(); }}// Show or hide the calendarfunction ShowCalendar() { if (this.isShowing()) { var StopTimer = true; this.getCalendar().style.zIndex = --ZCounter; this.getCalendar().style.visibility = 'hidden'; this.fixSelects(false); } else { var StopTimer = false; this.fixSelects(true); this.getCalendar().style.zIndex = ++ZCounter; this.getCalendar().style.visibility = 'visible'; } this.handleTimer(StopTimer); self.status = '';}// Hides the input elements when the "blank" month is selectedfunction SetElementStatus(Hide) { this.getDayList().style.visibility = (Hide) ? 'hidden' : 'visible'; this.getYearField().style.visibility = (Hide) ? 'hidden' : 'visible'; this.getCalendarLink().style.visibility = (Hide) ? 'hidden' : 'visible';}// Sets the date, based on the month selectedfunction CheckMonthChange(MonthList) { var DayList = this.getDayList(); if (MonthList.options[MonthList.selectedIndex].value == '') { DayList.selectedIndex = 0; this.hideElements(true); this.setHidden(''); } else { this.hideElements(false); if (this.isShowing()) { this.resetTimer(); // Gives the user more time to view the calendar with the newly-selected month this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars } var DayPick = FixDayList(DayList, GetDayCount(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value)); this.setPicked(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value, DayPick); }}// Sets the date, based on the day selectedfunction CheckDayChange(DayList) { if (this.isShowing()) this.show(); this.setPicked(this.picked.yearValue, this.picked.monthIndex, DayList.selectedIndex+1);}// Changes the date when a valid year has been enteredfunction CheckYearInput(YearField) { if ((YearField.value.length == YearField.defaultValue.length) && (YearField.defaultValue != YearField.value)) { if (this.isShowing()) { this.resetTimer(); // Gives the user more time to view the calendar with the newly-entered year this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars } var NewYear = GetGoodYear(YearField.value); var MonthList = this.getMonthList(); var NewDay = FixDayList(this.getDayList(), GetDayCount(NewYear, this.picked.monthIndex)); this.setPicked(NewYear, this.picked.monthIndex, NewDay); YearField.defaultValue = YearField.value; }}// Holds characteristics about a datefunction dateObject() { this.date = (arguments.length == 1) ? new Date(arguments[0]) : new Date(arguments[0], arguments[1], arguments[2]); this.yearValue = this.date.getFullYear(); this.monthIndex = this.date.getMonth(); this.monthName = MonthNames[this.monthIndex]; this.fullName = this.monthName + ' ' + this.yearValue; this.day = this.date.getDate(); this.dayCount = GetDayCount(this.yearValue, this.monthIndex); var FirstDate = new Date(this.yearValue, this.monthIndex, 1); this.firstDay = FirstDate.getDay();}// Keeps track of the date that goes into the hidden fieldfunction storedMonthObject(DateFormat, DateYear, DateMonth, DateDay) { dateObject.call(this, DateYear, DateMonth, DateDay); this.yearPad = this.yearValue.toString(); this.monthPad = (this.monthIndex < 9) ? '0' + String(this.monthIndex + 1) : this.monthIndex + 1; this.dayPad = (this.day < 10) ? '0' + this.day.toString() : this.day; this.monthShort = this.monthName.substr(0,3).toUpperCase(); // Formats the year value if (DateFormat != 'YYYYMMDD') { DateFormat.match(/(Y{2,4})$/); if (RegExp.$1.length == 2) this.yearPad = this.yearPad.substr(2); } // Formats the date if (/YYYYMMDD/.test(DateFormat)) this.formatted = this.yearPad + this.monthPad + this.dayPad; else { if (/MM?\/DD?\/Y{2,4}/.test(DateFormat)) var FirstPart = this.monthPad + '/' + this.dayPad + '/'; else if (/DD?\/MM?\/Y{2,4}/.test(DateFormat)) var FirstPart = this.dayPad + '/' + this.monthPad + '/'; else if (/DD?-((MON)|(MMM))-Y{2,4}/.test(DateFormat)) var FirstPart = this.dayPad + '-' + this.monthShort + '-'; else if (/((MON)|(MMM))-DD?-Y{2,4}/.test(DateFormat)) var FirstPart = this.monthShort + '-' + this.dayPad + '-'; this.formatted = FirstPart + this.yearPad; }}// Object for the current displayed monthfunction displayMonthObject(ParentObject, DateYear, DateMonth, DateDay) { dateObject.call(this, DateYear, DateMonth, DateDay); this.displayID = ParentObject.hiddenFieldName + '_Current_ID'; this.getDisplay = new Function('return document.getElementById(this.displayID)'); this.dayHover = DayCellHover; this.goCurrent = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(Today.getFullYear(),Today.getMonth());'); if (ParentObject.formNumber >= 0) this.getDisplay().innerHTML = this.fullName;}// Object for the previous/next buttonsfunction neighborMonthObject(ParentObject, IDText, DateMS) { dateObject.call(this, DateMS); this.buttonID = ParentObject.hiddenFieldName + '_' + IDText + '_ID'; this.hover = new Function('C','O','NeighborHover(C,O,this)'); this.getButton = new Function('return document.getElementById(this.buttonID)'); this.go = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(this.yearValue,this.monthIndex);'); if (ParentObject.formNumber >= 0) this.getButton().title = this.monthName;}// Sets the currently-displayed month objectfunction SetDisplayedMonth(DispYear, DispMonth) { this.displayed = new displayMonthObject(this, DispYear, DispMonth, 1); // Creates the previous and next month objects this.previous = new neighborMonthObject(this, 'Previous', this.displayed.date.getTime() - 86400000); this.next = new neighborMonthObject(this, 'Next', this.displayed.date.getTime() + (86400000 * (this.displayed.dayCount + 1))); // Creates the HTML for the calendar if (this.formNumber >= 0) this.getDayTable().innerHTML = this.buildCalendar();}// Sets the current selected datefunction SetPickedMonth(PickedYear, PickedMonth, PickedDay) { this.picked = new storedMonthObject(this.format, PickedYear, PickedMonth, PickedDay); this.setHidden(this.picked.formatted); this.setDisplayed(PickedYear, PickedMonth);}// The calendar objectfunction calendarObject(DateName, DateFormat, DefaultDate) { /* Properties */ this.hiddenFieldName = DateName; this.monthListName = DateName + '_Month'; this.dayListID = DateName + '_Day_ID'; this.yearFieldID = DateName + '_Year_ID'; this.monthDisplayID = DateName + '_Current_ID'; this.calendarID = DateName + '_ID'; this.dayTableID = DateName + '_DayTable_ID'; this.calendarLinkID = this.calendarID + '_Link'; this.timerID = this.calendarID + '_Timer'; this.objName = DateName + '_Object'; this.format = DateFormat; this.formNumber = -1; this.picked = null; this.displayed = null; this.previous = null; this.next = null; /* Methods */ this.setPicked = SetPickedMonth; this.setDisplayed = SetDisplayedMonth; this.checkYear = CheckYearInput; this.fixYear = FixYearInput; this.changeMonth = CheckMonthChange; this.changeDay = CheckDayChange; this.resetTimer = CalTimerReset; this.hideElements = SetElementStatus; this.show = ShowCalendar; this.handleTimer = DoTimer; this.iconHover = CalIconHover; this.buildCalendar = BuildCalendarDays; this.pickDay = PickDisplayDay; this.fixSelects = FixSelectLists; this.setHidden = new Function('D','if (this.formNumber >= 0) this.getHiddenField().value=D'); // Returns a reference to these elements this.getHiddenField = new Function('return document.forms[this.formNumber].elements[this.hiddenFieldName]'); this.getMonthList = new Function('return document.forms[this.formNumber].elements[this.monthListName]'); this.getDayList = new Function('return document.getElementById(this.dayListID)'); this.getYearField = new Function('return document.getElementById(this.yearFieldID)'); this.getCalendar = new Function('return document.getElementById(this.calendarID)'); this.getDayTable = new Function('return document.getElementById(this.dayTableID)'); this.getCalendarLink = new Function('return document.getElementById(this.calendarLinkID)'); this.getMonthDisplay = new Function('return document.getElementById(this.monthDisplayID)'); this.isShowing = new Function('return !(this.getCalendar().style.visibility != \'visible\')'); /* Constructor */ // Functions used only by the constructor function getMonthIndex(MonthAbbr) { // Returns the index (0-11) of the supplied month abbreviation for (var MonPos=0;MonPos<MonthNames.length;MonPos++) { if (MonthNames[MonPos].substr(0,3).toUpperCase() == MonthAbbr.toUpperCase()) break; } return MonPos; } function SetGoodDate(CalObj, Notify) { // Notifies the user about their bad default date, and sets the current system date CalObj.setPicked(Today.getFullYear(), Today.getMonth(), Today.getDate()); if (Notify) alert('WARNING: The supplied date is not in valid \'' + DateFormat + '\' format: ' + DefaultDate + '.\nTherefore, the current system date will be used instead: ' + CalObj.picked.formatted); } // Main part of the constructor if (DefaultDate == 'undefined') SetGoodDate(this, false); else { if (this.format == 'YYYYMMDD') { (/^\d{8}$/.test(DefaultDate)) ? this.setPicked(DefaultDate.substr(0,4), parseInt(DefaultDate.substr(4,2),10)-1, DefaultDate.substr(6,2)) : SetGoodDate(this, true); } else { if (/\//.test(this.format)) { if (/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/.test(DefaultDate)) { if (this.format.substr(0,1) == 'M') { var MonPart = RegExp.$1; var DayPart = RegExp.$2; } else { var MonPart = RegExp.$2; var DayPart = RegExp.$1; } this.setPicked(GetGoodYear(RegExp.$3), parseInt(MonPart,10)-1, DayPart); } else SetGoodDate(this, true); } else if (/-/.test(this.format)) { var REMonths = ''; for (var j=0;j<MonthNames.length;j++) { if (j > 0) REMonths += '|'; REMonths += MonthNames[j].substr(0,3).toUpperCase(); } if (this.format.substr(0,1) == 'D') { var DateRE = new RegExp('^(\\d{1,2})-(' + REMonths + ')-(\\d{2,4})$', 'i'); (DateRE.test(DefaultDate)) ? this.setPicked(GetGoodYear(RegExp.$3), getMonthIndex(RegExp.$2), RegExp.$1) : SetGoodDate(this, true); } else { var DateRE = new RegExp('^(' + REMonths + ')-(\\d{1,2})-(\\d{2,4})$', 'i'); (DateRE.test(DefaultDate)) ? this.setPicked(GetGoodYear(RegExp.$3), getMonthIndex(RegExp.$1), RegExp.$2) : SetGoodDate(this, true); } } } }}// Main function that creates the form elementsfunction DateInput(DateName, Required, DateFormat, DefaultDate) { if (DateName == undefined) document.writeln('<span style="color:red;font-size:' + FontSize + 'px;font-family:' + FontFamily + ';">ERROR: Missing required parameter in call to \'DateInput\': [name of hidden date field].</span>'); else { if (Required == undefined) Required = false; if (DateFormat == undefined) DateFormat = DefaultDateFormat; else if ((/^YYYYMMDD$/i.test(DateFormat)) || (/^((MM?)|(DD?))\/((MM?)|(DD?))\/Y{2,4}$/i.test(DateFormat)) || (/^((DD?)|((MON)|(MMM)))-((DD?)|((MON)|(MMM)))-Y{2,4}$/i.test(DateFormat))) DateFormat = DateFormat.toUpperCase(); else { var AlertMessage = 'WARNING: The supplied date format for the \'' + DateName + '\' field is not valid: ' + DateFormat + '\nTherefore, the default date format will be used instead: ' + DefaultDateFormat; var CurrentDate = new storedMonthObject(DefaultDateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate()); if (DefaultDate != undefined) AlertMessage += '\n\nThe supplied date cannot be interpreted with the invalid format.\nTherefore, the current system date will be used instead: ' + CurrentDate.formatted; DateFormat = DefaultDateFormat; DefaultDate = CurrentDate.formatted; alert(AlertMessage); } // Creates the calendar object! eval(DateName + '_Object=new calendarObject(\'' + DateName + '\',\'' + DateFormat + '\',\'' + DefaultDate + '\')'); if ((!Required) && (DefaultDate == undefined)) { var InitialStatus = ' style="visibility:hidden"'; var InitialDate = ''; } else { var InitialStatus = ''; var InitialDate = eval(DateName + '_Object.picked.formatted'); } if ((Required) && (DefaultDate == undefined)) DefaultDate = eval(DateName + '_Object.picked.formatted'); // Create the form elements with (document) { writeln('<input type="hidden" name="' + DateName + '" value="' + InitialDate + '">'); // Find this form number for (var f=0;f<forms.length;f++) { for (var e=0;e<forms[f].elements.length;e++) { if (typeof forms[f].elements[e].type == 'string') { if ((forms[f].elements[e].type == 'hidden') && (forms[f].elements[e].name == DateName)) { eval(DateName + '_Object.formNumber='+f); break; } } } } writeln('<table cellpadding="0" cellspacing="2"><tr>' + String.fromCharCode(13) + '<td valign="middle">'); writeln('<select name="' + DateName + '_Month" class="calendarDateInput" onChange="' + DateName + '_Object.changeMonth(this)">'); if (!Required) { var NoneSelected = (DefaultDate == undefined) ? ' selected' : ''; writeln('<option value=""' + NoneSelected + '></option>'); } for (var i=0;i<12;i++) { MonthSelected = ((DefaultDate != undefined) && (eval(DateName + '_Object.picked.monthIndex=='+i))) ? ' selected' : ''; writeln('<option value="' + i + '"' + MonthSelected + '>' + MonthNames[i].substr(0,3) + '</option>'); } writeln('</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle">'); writeln('<select' + InitialStatus + ' class="calendarDateInput" name="' + DateName + '_Day_ID" id="' + DateName + '_Day_ID" onChange="' + DateName + '_Object.changeDay(this)">'); for (var j=1;j<=eval(DateName + '_Object.picked.dayCount');j++) { DaySelected = ((DefaultDate != undefined) && eval(DateName + '_Object.picked.day=='+(j))) ? ' selected' : ''; writeln('<option' + DaySelected + '>' + j + '</option>'); } writeln('</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle">'); writeln('<input' + InitialStatus + ' class="calendarDateInput" type="text" name="' + DateName + '_Year_ID" id="' + DateName + '_Year_ID" size="' + eval(DateName + '_Object.picked.yearPad.length') + '" maxlength="' + eval(DateName + '_Object.picked.yearPad.length') + '" title="Year" value="' + eval(DateName + '_Object.picked.yearPad') + '" onKeyPress="return NumOnly(event)" onKeyUp="' + DateName + '_Object.checkYear(this)" onBlur="' + DateName + '_Object.fixYear(this)">'); write('<td valign="middle">' + String.fromCharCode(13) + '<a' + InitialStatus + ' id="' + DateName + '_ID_Link" href="java script:' + DateName + '_Object.show()" onMouseOver="return ' + DateName + '_Object.iconHover(true)" onMouseOut="return ' + DateName + '_Object.iconHover(false)"><img src="' + ImageURL + '" align="baseline" title="Calendar" border="0"></a> '); writeln('<span id="' + DateName + '_ID" style="position:absolute;visibility:hidden;width:' + (CellWidth * 7) + 'px;background-color:' + CalBGColor + ';border:1px solid dimgray;" onMouseOver="' + DateName + '_Object.handleTimer(true)" onMouseOut="' + DateName + '_Object.handleTimer(false)">'); writeln('<table width="' + (CellWidth * 7) + '" cellspacing="0" cellpadding="1">' + String.fromCharCode(13) + '<tr style="background-color:' + TopRowBGColor + ';">'); writeln('<td id="' + DateName + '_Previous_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + '" onClick="' + DateName + '_Object.previous.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.previous.hover(this,true)" onMouseOut="return ' + DateName + '_Object.previous.hover(this,false)" title="' + eval(DateName + '_Object.previous.monthName') + '"><img src="' + PrevURL + '" width="5" height="9"></td>'); writeln('<td id="' + DateName + '_Current_ID" style="cursor:pointer" align="center" class="calendarDateInput" style="height:' + CellHeight + '" colspan="5" onClick="' + DateName + '_Object.displayed.goCurrent()" onMouseOver="self.status=\'Click to view ' + eval(DateName + '_Object.displayed.fullName') + '\';return true;" onMouseOut="self.status=\'\';return true;" title="Show Current Month">' + eval(DateName + '_Object.displayed.fullName') + '</td>'); writeln('<td id="' + DateName + '_Next_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + '" onClick="' + DateName + '_Object.next.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.next.hover(this,true)" onMouseOut="return ' + DateName + '_Object.next.hover(this,false)" title="' + eval(DateName + '_Object.next.monthName') + '"><img src="' + NextURL + '" width="5" height="9"></td></tr>' + String.fromCharCode(13) + '<tr>'); for (var w=0;w<7;w++) writeln('<td width="18" align="center" class="calendarDateInput" style="height:' + CellHeight + ';width:' + CellWidth + ';font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">' + WeekDays[w] + '</td>'); writeln('</tr>' + String.fromCharCode(13) + '</table>' + String.fromCharCode(13) + '<span id="' + DateName + '_DayTable_ID">' + eval(DateName + '_Object.buildCalendar()') + '</span>' + String.fromCharCode(13) + '</span>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '</tr>' + String.fromCharCode(13) + '</table>'); } }} And where i call the script:<script>DateInput('Pickup_Date', true, 'DD-MON-YYYY','<%Response.write(stringvartoday)%>')</script><script>DateInput('DropOff_date', true, 'DD-MON-YYYY','<%Response.write(stringvartoday)%>')</script>I would really appreciate your help!Thanks guys!
  2. Well, here's the answer to my (stupid) question: I was copying the wrong files. Only to defence my self, here's what happened. I saved my webservice to a directory, C:\My Appl\MywebserviceI also had it in C:\inetpub\wwroot I was opening the webservice from C:\My Appl\Mywebservicebut it was being saved to C:\My Appl\Mywebservice. Naturally, I was copying the webservice from C:\My Appl\Mywebservice and paste to webserver. All files there were still dated as 2006! Fortunately i discovered my mistake a minute before throwing my pc out of the window!!! So for anyone else having the same problem, check where your files are stored!
  3. Hi! I have this webservice which I setup in my webserver. I made some changes in my copy in my computer and I want to update my webservice in the webserver.I overwrited the webservice, deleted it and re-configured it in IIS but nothing worked. When trying to test itI still get the old version Is there any file that I have to delete? What should I do?Thanks!
  4. Thanks for your reply jesh. I don't think that web services work in this way though. Correct me If I'm wrong but I think I cannot control the way dates are captured since I'm not the one developing the consumer. The only thing I could do is having three fileds for year, month, days like you suggested.
  5. I have a webservice with several functions. One function requires a parameter of type date. When testing my webservice I realised that this date should be given in no other format than YYYY-MM-DD. I would like to make a conversion function that will take as parameter the date and convert it to the above mentioned format. My problem is that I don't really know how the user will type the date. Could be: YYYY/MM/DD or MM/DD/YYYY or DD-MM-YYYY etc. Actually, a user while testing, gave the following date: YYYYMMDD. Is there any conversion function that I can use?
  6. You caould also use a template as your layout and adjust all your page to that template.Dreamweaver offers a nice solution to that.
  7. Can I pass variables to a file that I run directly from my computer? Like: C:\test.html?x=5 I don't want to use any kind of server including the IIS.
  8. it9888

    SQL problem

    I solved my problem. For anyone facing the same proble in the future, here's the solution: Use '# #' for the dates in your SQL statement when using Access. Really stupid ha? I forgot to use a couple of # and I spent a whole day trying to figure out what was wrong. Have a nice day ev1!
  9. it9888

    SQL problem

    I have a web service and in one web method i use the following SQL: SELECT Distinct RGR.Rate_Code, RGR.Scale_Name, RGR.Rgr_Group, RGR.Rgr_RateBuy, RGR.Rgr_Excess, RGR.Rgr_RateSell, Scale.Scale_Days, Gr.Gr_Code, Scale.Scale_ToDays, Supplier.Vat_Code, Supplier.Supplier_Country, Supplier.Supplier_Name, RGR.Rgr_GrSipp, Gr.Gr_VehType, Rate.Rate_FromDate, rate.Rate_Level, rate.Rate_EndingDate, Supplier.Supplier_City, Rate.Curr_Code, Gr.Gr_VehEngSize, Gr.Gr_VehAC, Gr.Gr_VehCLS, rate.Rate_Type, Gr.Gr_VehDoors, Gr.Gr_VehpPWS, Gr.Gr_VehABG, Gr.Gr_VehRC, Supplier.Supplier_Code, Gr.Gr_VehSeat, Gr.TheftExcess FROM (Gr INNER JOIN (((RGR INNER JOIN Scale ON (RGR.Rate_Code = Scale.Rate_Code) AND (RGR.Scale_Name = Scale.Scale_Name)) INNER JOIN rate ON RGR.Rate_Code = rate.Rate_Code) INNER JOIN Supplier ON rate.Supplier_Code = Supplier.Supplier_Code) ON (Gr.Gr_Supplier = Supplier.Supplier_Code) AND (Gr.Gr_SippCode = RGR.Rgr_GrSipp)) INNER JOIN Location ON Supplier.Supplier_Code = Location.Supplier_Code WHERE (((rate.Rate_FromDate)<=2/24/2007) AND ((rate.Rate_EndingDate)>=2/28/2007) AND ( Rate_level=1 Or Rate_level=2 Or Rate_level=3 Or Rate_level=4 Or Rate_level=5) AND ((Scale.Scale_Days)<=4) AND ((Scale.Scale_ToDays)>=4) AND ((Supplier.Supplier_Country)='COUNTRY') AND ((Location.City)='CITY')) ORDER BY RGR.Rgr_Group; I get no results. Then I tell to my web service to return this SQL as text as the result of it. I copy and test this SQL in Access. Again no result. When I go in my criteria and re-write even one letter, for example, If i delete and rewrite CITY, then I get results. How does this happen? I don't change anything from my SQL. One time i don't get results and the other i do. This is really weird. Please heeeeeelp!!!!
  10. it9888

    Loading external url

    I haven't thought of that. I will ask about it, thanx jesh! Otherwise I will use frames and try to be happy about it! Thank you all!
  11. it9888

    Loading external url

    I need to display a form that is hosted on another site. I tried using asp in a frame, I named that frame as something.asp but when I call my frameset, I get a message "Do you want to open 'something.asp' or save it in your computer", like I'm downloading a file. I haven't used frames before, and I would rather avoid using them but If this is the only method I will go for it. Any suggestions?
  12. I think that you need to check If there's a value in the table before trying to retrieve it.This works for me but I'm using vbscript. If not recordset.EOF then.........End if Try finding something similar.
  13. it9888

    Loading external url

    Hi ev1,I have a problem and I would appreciate your help.I'm developing a website for car rentals. This website gets a booking form from another website.I need to load this booking form in my website. How can I do that? If i use framesets and load the url then I think I can't have asp written in my frames. I do not want to use popup windows since I want the booking form to be displayed in the index page when loaded. What other options do i have? Please help!!!!
  14. Thanks jesh,I will try that and let you know.I really appreciate your help.
  15. Hi all,I hope you can help me with this one. I have a public function in a web service and i need to pass some parameters in it. Some of them are optional and some are not. How do i define that some of my parameters are optional? Here's my code: <WebMethod(Description:="")> _ Public Function ShowReservation(ByVal myusername As String, ByVal mypassword As String, ByVal MyResNo As String, ByVal FromDate As Date, ByVal ToDate As Date) As DataSet Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings("DSN")) Dim objDA As OleDbDataAdapter Dim objDS As New DataSet Dim SqlString, clientno As String clientno = GetClientNo(myusername, mypassword) If UserExists(myusername, mypassword) Then SqlString = "" SqlString = SqlString & " Select Country, ResNo, RegDate, Hirer From Res " SqlString = SqlString & " Where ClientNo='" & clientno & "'" If MyResNo <> "" Then SqlString = SqlString & " And Res_No='" & MyResNo & "'" End If objDA = New OleDbDataAdapter(SqlString, objConn) objDA.Fill(objDS, "Reservation") objConn.Close() Return objDS End If End Function Tha paramateres MyResNo, FromDate ,ToDate should be optional.Any ideas? Thanxit9888
×
×
  • Create New...