login  Naam:   Wachtwoord: 
Registreer je!
 Forum

[JavaScript] Kalender Input script aanpassen

Offline Mesh - 20/05/2008 11:10
Avatar van MeshNieuw lid Voor een registratiesysteem maken wij gebruik van het volgende kalender script. Bij het inladen wordt de datum van vandaag in het input field geladen. Indien de registratie op een andere dag heeft plaatsgevonden kan de gebruiker op het input field klikken en dan opent er een kalender waatr de gebruiker eenvoudig een andere datum kan selecteren.

  1. // +------------------------------------------------------------+
  2. // | Popup Calendar(Window) |
  3. // +------------------------------------------------------------+
  4. // | Last Modified: 22-Dec-2005 |
  5. // | Web Site: http://www.yxscripts.com |
  6. // | EMail: m_yangxin@hotmail.com |
  7. // +------------------------------------------------------------+
  8. // | Copyright 2002 Xin Yang All Rights Reserved. |
  9. // | This version featured on Dynamic Drive |
  10. // | (http://www.dynamicdrive.com) |
  11. // +------------------------------------------------------------+
  12.  
  13. // default settings
  14. var fontFace="verdana";
  15. var fontSize=9;
  16.  
  17. var titleWidth=90;
  18. var titleMode=1;
  19. var dayWidth=12;
  20. var dayDigits=1;
  21.  
  22. var titleColor="#cccccc";
  23. var daysColor="#cccccc";
  24. var bodyColor="#ffffff";
  25. var dayColor="#ffffff";
  26. var currentDayColor="#333333";
  27. var footColor="#cccccc";
  28. var borderColor="#333333";
  29.  
  30. var titleFontColor = "#333333";
  31. var daysFontColor = "#333333";
  32. var dayFontColor = "#333333";
  33. var currentDayFontColor = "#ffffff";
  34. var footFontColor = "#333333";
  35.  
  36. var calFormat = "dd/mm/yyyy";
  37.  
  38. var weekDay = 0;
  39. // ------
  40.  
  41. // codes
  42. var calWidth=200, calHeight=200, calOffsetX=-200, calOffsetY=16;
  43. var calWin=null;
  44. var winX=0, winY=0;
  45. var cal="cal";
  46. var cals=new Array();
  47. var currentCal=null;
  48.  
  49. var yxMonths=new Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");
  50. var yxDays=new Array("Sunday", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag");
  51. var yxLinks=new Array("[sluiten]", "[verwijder]");
  52.  
  53. var nav=navigator.userAgent.toLowerCase();;
  54. var isOpera=(nav.indexOf("opera")!=-1)?true:false;
  55. var isOpera5=(nav.indexOf("opera 5")!=-1 || nav.indexOf("opera/5")!=-1)?true:false;
  56. var isOpera6=(isOpera && parseInt(navigator.appVersion)>=6)?true:false;
  57. var isN6=(nav.indexOf("gecko")!=-1);
  58. var isN4=(document.layers)?true:false;
  59. var isMac=(nav.indexOf("mac")!=-1);
  60. var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;
  61.  
  62. if (isN4) {
  63. fontSize+=2;
  64. }
  65.  
  66. var span2="</span>";
  67.  
  68. function span1(tag) {
  69. return "<span class='"+tag+"'>";
  70. }
  71. function spanx(tag, color) {
  72. return "."+tag+" { font-family:"+fontFace+"; font-size:"+fontSize+"px; color:"+color+"; }\n";
  73. }
  74.  
  75. function a1(tag) {
  76. return "<a class='"+tag+"' href=";
  77. }
  78.  
  79. function ax(tag, color) {
  80. return "."+tag+" { text-decoration:none; color:"+color+"; }\n";
  81. }
  82.  
  83. function calOBJ(name, title, field, form) {
  84. this.name = name;
  85. this.title = title;
  86. this.field = field;
  87. this.formName = form;
  88. this.form = null
  89. }
  90.  
  91. function setFont(font, size) {
  92. if (font != "") {
  93. fontFace=font;
  94. }
  95. if (size > 0) {
  96. fontSize=size;
  97.  
  98. if (isN4) {
  99. fontSize+=2;
  100. }
  101. }
  102. }
  103.  
  104. function setWidth(tWidth, tMode, dWidth, dDigits) {
  105. if (tWidth > 0) {
  106. titleWidth=tWidth;
  107. }
  108. if (tMode == 1 || tMode == 2) {
  109. titleMode=tMode;
  110. }
  111. if (dWidth > 0) {
  112. dayWidth=dWidth;
  113. }
  114. if (dDigits > 0) {
  115. dayDigits=dDigits;
  116. }
  117. }
  118.  
  119. function setColor(tColor, dsColor, bColor, dColor, cdColor, fColor, bdColor) {
  120. if (tColor != "") {
  121. titleColor=tColor;
  122. }
  123. if (dsColor != "") {
  124. daysColor=dsColor;
  125. }
  126. if (bColor != "") {
  127. bodyColor=bColor;
  128. }
  129. if (dColor != "") {
  130. dayColor=dColor;
  131. }
  132. if (cdColor != "") {
  133. currentDayColor=cdColor;
  134. }
  135. if (fColor != "") {
  136. footColor=fColor;
  137. }
  138. if (bdColor != "") {
  139. borderColor=bdColor;
  140. }
  141. }
  142.  
  143. function setFontColor(tColorFont, dsColorFont, dColorFont, cdColorFont, fColorFont) {
  144. if (tColorFont != "") {
  145. titleFontColor=tColorFont;
  146. }
  147. if (dsColorFont != "") {
  148. daysFontColor=dsColorFont;
  149. }
  150. if (dColorFont != "") {
  151. dayFontColor=dColorFont;
  152. }
  153. if (cdColorFont != "") {
  154. currentDayFontColor=cdColorFont;
  155. }
  156. if (fColorFont != "") {
  157. footFontColor=fColorFont;
  158. }
  159. }
  160.  
  161. function setFormat(format) {
  162. calFormat = format;
  163. }
  164.  
  165. function setSize(width, height, ox, oy) {
  166. if (width > 0) {
  167. calWidth=width;
  168. }
  169. if (height > 0) {
  170. calHeight=height;
  171. }
  172.  
  173. calOffsetX=ox;
  174. calOffsetY=oy;
  175. }
  176.  
  177. function setWeekDay(wDay) {
  178. if (wDay == 0 || wDay == 1) {
  179. weekDay = wDay;
  180. }
  181. }
  182.  
  183. function setMonthNames(janName, febName, marName, aprName, mayName, junName, julName, augName, sepName, octName, novName, decName) {
  184. if (janName != "") {
  185. yxMonths[0] = janName;
  186. }
  187. if (febName != "") {
  188. yxMonths[1] = febName;
  189. }
  190. if (marName != "") {
  191. yxMonths[2] = marName;
  192. }
  193. if (aprName != "") {
  194. yxMonths[3] = aprName;
  195. }
  196. if (mayName != "") {
  197. yxMonths[4] = mayName;
  198. }
  199. if (junName != "") {
  200. yxMonths[5] = junName;
  201. }
  202. if (julName != "") {
  203. yxMonths[6] = julName;
  204. }
  205. if (augName != "") {
  206. yxMonths[7] = augName;
  207. }
  208. if (sepName != "") {
  209. yxMonths[8] = sepName;
  210. }
  211. if (octName != "") {
  212. yxMonths[9] = octName;
  213. }
  214. if (novName != "") {
  215. yxMonths[10] = novName;
  216. }
  217. if (decName != "") {
  218. yxMonths[11] = decName;
  219. }
  220. }
  221.  
  222. function setDayNames(sunName, monName, tueName, wedName, thuName, friName, satName) {
  223. if (sunName != "") {
  224. yxDays[0] = sunName;
  225. yxDays[7] = sunName;
  226. }
  227. if (monName != "") {
  228. yxDays[1] = monName;
  229. }
  230. if (tueName != "") {
  231. yxDays[2] = tueName;
  232. }
  233. if (wedName != "") {
  234. yxDays[3] = wedName;
  235. }
  236. if (thuName != "") {
  237. yxDays[4] = thuName;
  238. }
  239. if (friName != "") {
  240. yxDays[5] = friName;
  241. }
  242. if (satName != "") {
  243. yxDays[6] = satName;
  244. }
  245. }
  246.  
  247. function setLinkNames(closeLink, clearLink) {
  248. if (closeLink != "") {
  249. yxLinks[0] = closeLink;
  250. }
  251. if (clearLink != "") {
  252. yxLinks[1] = clearLink;
  253. }
  254. }
  255.  
  256. function addCalendar(name, title, field, form) {
  257. cals[cals.length] = new calOBJ(name, title, field, form);
  258. }
  259.  
  260. function findCalendar(name) {
  261. for (var i = 0; i < cals.length; i++) {
  262. if (cals[i].name == name) {
  263. if (cals[i].form == null) {
  264. if (cals[i].formName == "") {
  265. if (document.forms[0]) {
  266. cals[i].form = document.forms[0];
  267. }
  268. }
  269. else if (document.forms[cals[i].formName]) {
  270. cals[i].form = document.forms[cals[i].formName];
  271. }
  272. }
  273.  
  274. return cals[i];
  275. }
  276. }
  277.  
  278. return null;
  279. }
  280.  
  281. function getDayName(y,m,d) {
  282. var wd=new Date(y,m,d);
  283. return yxDays[wd.getDay()].substring(0,3);
  284. }
  285.  
  286. function getMonthFromName(m3) {
  287. for (var i = 0; i < yxMonths.length; i++) {
  288. if (yxMonths[i].toLowerCase().substring(0,3) == m3.toLowerCase()) {
  289. return i;
  290. }
  291. }
  292.  
  293. return 0;
  294. }
  295.  
  296. function getFormat() {
  297. var calF = calFormat;
  298.  
  299. calF = calF.replace(/\\/g, '\\\\');
  300. calF = calF.replace(/\//g, '\\\/');
  301. calF = calF.replace(/\[/g, '\\\[');
  302. calF = calF.replace(/\]/g, '\\\]');
  303. calF = calF.replace(/\(/g, '\\\(');
  304. calF = calF.replace(/\)/g, '\\\)');
  305. calF = calF.replace(/\{/g, '\\\{');
  306. calF = calF.replace(/\}/g, '\\\}');
  307. calF = calF.replace(/\</g, '\\\<');
  308. calF = calF.replace(/\>/g, '\\\>');
  309. calF = calF.replace(/\|/g, '\\\|');
  310. calF = calF.replace(/\*/g, '\\\*');
  311. calF = calF.replace(/\?/g, '\\\?');
  312. calF = calF.replace(/\+/g, '\\\+');
  313. calF = calF.replace(/\^/g, '\\\^');
  314. calF = calF.replace(/\$/g, '\\\$');
  315.  
  316. calF = calF.replace(/dd/i, '\\d\\d');
  317. calF = calF.replace(/mm/i, '\\d\\d');
  318. calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');
  319. calF = calF.replace(/day/i, '\\w\\w\\w');
  320. calF = calF.replace(/mon/i, '\\w\\w\\w');
  321.  
  322. return new RegExp(calF);
  323. }
  324.  
  325. function getDateNumbers(date) {
  326. var y, m, d;
  327.  
  328. var yIdx = calFormat.search(/yyyy/i);
  329. var mIdx = calFormat.search(/mm/i);
  330. var m3Idx = calFormat.search(/mon/i);
  331. var dIdx = calFormat.search(/dd/i);
  332.  
  333. y=date.substring(yIdx,yIdx+4)-0;
  334. if (mIdx != -1) {
  335. m=date.substring(mIdx,mIdx+2)-1;
  336. }
  337. else {
  338. var m = getMonthFromName(date.substring(m3Idx,m3Idx+3));
  339. }
  340. d=date.substring(dIdx,dIdx+2)-0;
  341.  
  342. return new Array(y,m,d);
  343. }
  344.  
  345. function hideCal() {
  346. document.Registration.firstinput.disabled=false;
  347. calWin.close();
  348. calWin = null;
  349. window.status = "";
  350. }
  351.  
  352. function getLeftIE(x,m) {
  353. var dx=0;
  354. if (x.tagName=="TD"){
  355. dx=x.offsetLeft;
  356. }
  357. else if (x.tagName=="TABLE") {
  358. dx=x.offsetLeft;
  359. if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  360. }
  361. return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
  362. }
  363. function getTopIE(x,m) {
  364. var dy=0;
  365. if (x.tagName=="TR"){
  366. dy=x.offsetTop;
  367. }
  368. else if (x.tagName=="TABLE") {
  369. dy=x.offsetTop;
  370. if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  371. }
  372. return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
  373. }
  374.  
  375. function getLeftN4(l) { return l.pageX; }
  376. function getTopN4(l) { return l.pageY; }
  377.  
  378. function getLeftN6(l) { return l.offsetLeft; }
  379. function getTopN6(l) { return l.offsetTop; }
  380.  
  381. function lastDay(d) {
  382. var yy=d.getFullYear(), mm=d.getMonth();
  383. for (var i=31; i>=28; i--) {
  384. var nd=new Date(yy,mm,i);
  385. if (mm == nd.getMonth()) {
  386. return i;
  387. }
  388. }
  389. }
  390.  
  391. function firstDay(d) {
  392. var yy=d.getFullYear(), mm=d.getMonth();
  393. var fd=new Date(yy,mm,1);
  394. return fd.getDay();
  395. }
  396.  
  397. function dayDisplay(i) {
  398. if (dayDigits == 0) {
  399. return yxDays[i];
  400. }
  401. else {
  402. return yxDays[i].substring(0,dayDigits);
  403. }
  404. }
  405.  
  406. function calTitle(d) {
  407. var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];
  408. var s;
  409.  
  410. if (titleMode == 2) {
  411. s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-10)'>&nbsp;&#171;</a>&nbsp;"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+yy+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>&nbsp;&#155;</a>&nbsp;"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(10)'>&#187;&nbsp;</a></b>"+span2+"</td></tr><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>&nbsp;&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+mm+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'>&nbsp;&#155;&nbsp;</a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  412. }
  413. else {
  414. s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>&nbsp;&#171;</a>&nbsp;"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><nobr><b>"+span1("title")+mm+" "+yy+span2+"</b></nobr></td><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'>&nbsp;&#155;</a>&nbsp;"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>&#187;&nbsp;</a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  415. }
  416.  
  417. for (var i=weekDay; i<weekDay+7; i++) {
  418. s+="<td width='"+dayWidth+"'>"+span1("days")+dayDisplay(i)+span2+"</td>";
  419. }
  420.  
  421. s+="</tr>";
  422.  
  423. return s;
  424. }
  425.  
  426. function calHeader() {
  427. return "<head>\n<title>"+currentCal.title+"</title>\n<style type='text/css'>\n"+spanx("title",titleFontColor)+spanx("days",daysFontColor)+spanx("foot",footColor)+spanx("day",dayFontColor)+spanx("currentDay",currentDayFontColor)+ax("titlea",titleFontColor)+ax("daya",dayFontColor)+ax("currenta",currentDayFontColor)+ax("foota",footFontColor)+"</style>\n</head>\n<body>\n<table align='center' border='0' bgcolor='"+borderColor+"' cellspacing='0' cellpadding='1'><tr><td>\n<table cellspacing='1' cellpadding='3' border='0'>";
  428. }
  429.  
  430. function calFooter() {
  431. return "<tr bgcolor='"+footColor+"'><td colspan='7' align='center'>"+span1("foot")+"<b>"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.hideCal) window.opener.hideCal()'>"+yxLinks[0]+"</a>&nbsp;&nbsp;"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.clearDate) window.opener.clearDate()'>"+yxLinks[1]+"</a></b>"+span2+"</td></tr></table>\n</td></tr></table>\n</body>";
  432. }
  433.  
  434. function calBody(d,day) {
  435. var s="", dayCount=1, fd=firstDay(d), ld=lastDay(d);
  436.  
  437. if (weekDay > 0 && fd == 0) {
  438. fd = 7;
  439. }
  440.  
  441. for (var i=0; i<6; i++) {
  442. s+="<tr align='center' bgcolor='"+bodyColor+"'>";
  443. for (var j=weekDay; j<weekDay+7; j++) {
  444. if (i*7+j<fd || dayCount>ld) {
  445. s+="<td>"+span1("day")+"&nbsp;"+span2+"</td>";
  446. }
  447. else {
  448. var bgColor=dayColor;
  449. var fgTag="day";
  450. var fgTagA="daya";
  451. if (dayCount==day) {
  452. bgColor=currentDayColor;
  453. fgTag="currentDay";
  454. fgTagA="currenta";
  455. }
  456.  
  457. s+="<td bgcolor='"+bgColor+"'>"+span1(fgTag)+a1(fgTagA)+"'javascript: if (window.opener && !window.opener.closed && window.opener.pickDate) window.opener.pickDate("+dayCount+")'>"+(dayCount++)+"</a>"+span2+"</td>";
  458. }
  459. }
  460. s+="</tr>";
  461. }
  462.  
  463. return s;
  464. }
  465.  
  466. function moveYear(dy) {
  467. cY+=dy;
  468. var nd=new Date(cY,cM,1);
  469. changeCal(nd);
  470. }
  471.  
  472. function prepMonth(m) {
  473. cM=m-1;
  474. if (cM<0) { cM=11; cY--; }
  475. var nd=new Date(cY,cM,1);
  476. changeCal(nd);
  477. }
  478.  
  479. function nextMonth(m) {
  480. cM=m+1;
  481. if (cM>11) { cM=0; cY++;}
  482. var nd=new Date(cY,cM,1);
  483. changeCal(nd);
  484. }
  485.  
  486. function changeCal(d) {
  487. var dd = 0;
  488.  
  489. if (currentCal != null) {
  490. var calRE = getFormat();
  491.  
  492. if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
  493. var cd = getDateNumbers(currentCal.form[currentCal.field].value);
  494. if (cd[0] == d.getFullYear() && cd[1] == d.getMonth()) {
  495. dd=cd[2];
  496. }
  497. }
  498. else {
  499. var cd = new Date();
  500. if (cd.getFullYear() == d.getFullYear() && cd.getMonth() == d.getMonth()) {
  501. dd=cd.getDate();
  502. }
  503. }
  504. }
  505.  
  506. var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();
  507.  
  508. calWin.document.open();
  509. calWin.document.write(calendar);
  510. calWin.document.close();
  511. }
  512.  
  513. function markClick(e) {
  514. if (isIE || isOpera6) {
  515. winX=event.screenX;
  516. winY=event.screenY;
  517. }
  518. else if (isN4 || isN6) {
  519. winX=e.screenX;
  520. winY=e.screenY;
  521.  
  522. document.routeEvent(e);
  523. }
  524.  
  525. if (isN4 || isN6) {
  526. document.routeEvent(e);
  527. }
  528. else {
  529. event.cancelBubble=false;
  530. }
  531.  
  532. return true;
  533. }
  534.  
  535. function showCal(name) {
  536. var lastCal=currentCal;
  537. var d=new Date(), hasCal=false;
  538.  
  539. currentCal = findCalendar(name);
  540.  
  541. if (currentCal != null && currentCal.form != null && currentCal.form[currentCal.field]) {
  542. var calRE = getFormat();
  543.  
  544. if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
  545. var cd = getDateNumbers(currentCal.form[currentCal.field].value);
  546. d=new Date(cd[0],cd[1],cd[2]);
  547.  
  548. cY=cd[0];
  549. cM=cd[1];
  550. dd=cd[2];
  551. }
  552. else {
  553. cY=d.getFullYear();
  554. cM=d.getMonth();
  555. dd=d.getDate();
  556. }
  557.  
  558. var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();
  559.  
  560. if (calWin != null && typeof(calWin.closed)!="undefined" && !calWin.closed) {
  561. hasCal=true;
  562. calWin.moveTo(winX+calOffsetX,winY+calOffsetY);
  563. }
  564.  
  565. if (!hasCal) {
  566. if (isIE || isOpera6) {
  567. calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",left="+(winX+calOffsetX)+",top="+(winY+calOffsetY));
  568. }
  569. else {
  570. calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",screenx="+(winX+calOffsetX)+",screeny="+(winY+calOffsetY));
  571. }
  572. }
  573.  
  574. calWin.document.open();
  575. calWin.document.write(calendar);
  576. calWin.document.close();
  577.  
  578. calWin.focus();
  579. }
  580. else {
  581. if (currentCal == null) {
  582. window.status = "Calendar ["+name+"] not found.";
  583. }
  584. else if (!currentCal.form) {
  585. window.status = "Form ["+currentCal.formName+"] not found.";
  586. }
  587. else if (!currentCal.form[currentCal.field]) {
  588. window.status = "Form Field ["+currentCal.formName+"."+currentCal.field+"] not found.";
  589. }
  590.  
  591. if (lastCal != null) {
  592. currentCal = lastCal;
  593. }
  594. }
  595. }
  596.  
  597. function get2Digits(n) {
  598. return ((n<10)?"0":"")+n;
  599. }
  600.  
  601. function clearDate() {
  602. currentCal.form[currentCal.field].value="";
  603. hideCal();
  604. }
  605.  
  606. function pickDate(d) {
  607. hideCal();
  608. window.focus();
  609.  
  610. var date=calFormat;
  611. date = date.replace(/yyyy/i, cY);
  612. date = date.replace(/mm/i, get2Digits(cM+1));
  613. date = date.replace(/MON/, yxMonths[cM].substring(0,3).toUpperCase());
  614. date = date.replace(/Mon/i, yxMonths[cM].substring(0,3));
  615. date = date.replace(/dd/i, get2Digits(d));
  616. date = date.replace(/DAY/, getDayName(cY,cM,d).toUpperCase());
  617. date = date.replace(/day/i, getDayName(cY,cM,d));
  618.  
  619. currentCal.form[currentCal.field].value=date;
  620. // IE5/Mac needs focus to show the value, weird.
  621. currentCal.form[currentCal.field].focus();
  622.  
  623. sendRequest('submit','NieuweRegistratie.do?page=1&step=final');
  624. }
  625. // ------
  626.  
  627. // user functions
  628. function checkDate(name) {
  629. var thisCal = findCalendar(name);
  630.  
  631. if (thisCal != null && thisCal.form != null && thisCal.form[thisCal.field]) {
  632. var calRE = getFormat();
  633.  
  634. if (calRE.test(thisCal.form[thisCal.field].value)) {
  635. return 0;
  636. }
  637. else {
  638. return 1;
  639. }
  640. }
  641. else {
  642. return 2;
  643. }
  644. }
  645.  
  646. function getCurrentDate() {
  647. var date=calFormat, d = new Date();
  648. date = date.replace(/yyyy/i, d.getFullYear());
  649. date = date.replace(/mm/i, get2Digits(d.getMonth()+1));
  650. date = date.replace(/dd/i, get2Digits(d.getDate()));
  651.  
  652. return date;
  653. }
  654.  
  655. function compareDates(date1, date2) {
  656. var calRE = getFormat();
  657. var d1, d2;
  658.  
  659. if (calRE.test(date1)) {
  660. d1 = getNumbers(date1);
  661. }
  662. else {
  663. d1 = getNumbers(getCurrentDate());
  664. }
  665.  
  666. if (calRE.test(date2)) {
  667. d2 = getNumbers(date2);
  668. }
  669. else {
  670. d2 = getNumbers(getCurrentDate());
  671. }
  672.  
  673. var dStr1 = d1[0] + "" + d1[1] + "" + d1[2];
  674. var dStr2 = d2[0] + "" + d2[1] + "" + d2[2];
  675.  
  676. if (dStr1 == dStr2) {
  677. return 0;
  678. }
  679. else if (dStr1 > dStr2) {
  680. return 1;
  681. }
  682. else {
  683. return -1;
  684. }
  685. }
  686.  
  687. function getNumbers(date) {
  688. var calRE = getFormat();
  689. var y, m, d;
  690.  
  691. if (calRE.test(date)) {
  692. var yIdx = calFormat.search(/yyyy/i);
  693. var mIdx = calFormat.search(/mm/i);
  694. var m3Idx = calFormat.search(/mon/i);
  695. var dIdx = calFormat.search(/dd/i);
  696.  
  697. y=date.substring(yIdx,yIdx+4);
  698. if (mIdx != -1) {
  699. m=date.substring(mIdx,mIdx+2);
  700. }
  701. else {
  702. var mm=getMonthFromName(date.substring(m3Idx,m3Idx+3))+1;
  703. m=(mm<10)?("0"+mm):(""+mm);
  704. }
  705. d=date.substring(dIdx,dIdx+2);
  706.  
  707. return new Array(y,m,d);
  708. }
  709. else {
  710. return new Array("", "", "");
  711. }
  712. }
  713. // ------
  714.  
  715. if (isN4 || isN6) {
  716. document.captureEvents(Event.CLICK);
  717. }
  718. document.onclick=markClick;


Echter opent deze de kalender in een popup. Dit gebeurt in FireFox netjes, maar in IE7 (6 nog niet kunnen testen?) wordt hiervoor een niet tabblad geopend.

Zou dit dus willen verbeteren door of deze alsnog in een popup te laten openen of bijvoorbeeld de kalender in een floating div te laten openen. Maar weet niet hoe ik dit moet aanpakken.

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.22s