www.webdeveloper.com
Results 1 to 2 of 2

Thread: help..! script help needed

  1. #1
    Join Date
    Mar 2004
    Posts
    18

    Smile help..! script help needed

    hi! i've download a script that allows me to have a pop up calendar that when the user clicks on the date, it will automatically input the date into a text box. however, i can't seem to go back in time. i can't put in dates that are in the previous months. i need to do so..is there anyone who can look at these codes and solve my problem? thanks
    ---------------------------------------------------------------------------------------------------------------

    var ppcDF = "m/d/Y";
    var ppcMN = new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December");
    var ppcWN = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var ppcER = new Array(4);
    ppcER[0] = "Required DHTML functions are not supported in this browser.";
    ppcER[1] = "Target form field is not assigned or not accessible.";
    ppcER[2] = "Sorry, the chosen date is not acceptable. Please read instructions on the page.";
    ppcER[3] = "Unknown error occured while executing this script.";
    var ppcUC = false;
    var ppcUX = 4;
    var ppcUY = 4;



    var ppcIE=(navigator.appName == "Microsoft Internet Explorer");
    var ppcNN=((navigator.appName == "Netscape")&&(document.layers));
    var ppcTT="<table width=\"200\" cellspacing=\"1\" cellpadding=\"2\" border=\"1\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\">\n";
    var ppcCD=ppcTT;var ppcFT="<font face=\"MS Sans Serif, sans-serif\" size=\"1\" color=\"#000000\">";var ppcFC=true;
    var ppcTI=false;var ppcSV=null;var ppcRL=null;var ppcXC=null;var ppcYC=null;
    var ppcML=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    var ppcWE=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var ppcNow=new Date();var ppcPtr=new Date();
    if (ppcNN) {
    window.captureEvents(Event.RESIZE);
    window.onresize = restoreLayers;
    document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
    document.onmousedown = recordXY;
    document.onmouseup = confirmXY;}
    function restoreLayers(e) {
    if (ppcNN) {
    with (window.document) {
    open("text/html");
    write("<html><head><title>Restoring the layer structure...</title></head>");
    write("<body bgcolor=\"#FFFFFF\" onLoad=\"history.go(-1)\">");
    write("</body></html>");
    close();}}}
    function recordXY(e) {
    if (ppcNN) {
    ppcXC = e.x;
    ppcYC = e.y;
    document.routeEvent(e);}}
    function confirmXY(e) {
    if (ppcNN) {
    ppcXC = (ppcXC == e.x) ? e.x : null;
    ppcYC = (ppcYC == e.y) ? e.y : null;
    document.routeEvent(e);}}
    function getCalendarFor(target,rules) {
    ppcSV = target;
    ppcRL = rules;
    if (ppcFC) {setCalendar();ppcFC = false;}
    if ((ppcSV != null)&&(ppcSV)) {
    if (ppcIE) {
    var obj = document.all['PopUpCalendar'];
    obj.style.left = document.body.scrollLeft+event.clientX;
    obj.style.top = document.body.scrollTop+event.clientY;
    obj.style.visibility = "visible";}
    else if (ppcNN) {
    var obj = document.layers['PopUpCalendar'];
    obj.left = ppcXC
    obj.top = ppcYC
    obj.visibility = "show";}
    else {showError(ppcER[0]);}}
    else {showError(ppcER[1]);}}
    function switchMonth(param) {
    var tmp = param.split("|");
    setCalendar(tmp[0],tmp[1]);}
    function moveMonth(dir) {
    var obj = null;
    var limit = false;
    var tmp,dptrYear,dptrMonth;
    if (ppcIE) {obj = document.ppcMonthList.sItem;}
    else if (ppcNN) {obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
    else {showError(ppcER[0]);}
    if (obj != null) {
    if ((dir.toLowerCase() == "back")&&(obj.selectedIndex > 0)) {obj.selectedIndex--;}
    else if ((dir.toLowerCase() == "forward")&&(obj.selectedIndex < 12)) {obj.selectedIndex++;}
    else {limit = true;}}
    if (!limit) {
    tmp = obj.options[obj.selectedIndex].value.split("|");
    dptrYear = tmp[0];
    dptrMonth = tmp[1];
    setCalendar(dptrYear,dptrMonth);}
    else {
    if (ppcIE) {
    obj.style.backgroundColor = "#FF0000";
    window.setTimeout("document.ppcMonthList.sItem.style.backgroundColor = '#FFFFFF'",50);}}}
    function selectDate(param) {
    var arr = param.split("|");
    var year = arr[0];
    var month = arr[1];
    var date = arr[2];
    var ptr = parseInt(date);
    ppcPtr.setDate(ptr);
    if ((ppcSV != null)&&(ppcSV)) {
    if (validDate(date)) {ppcSV.value = dateFormat(year,month,date);hideCalendar();}
    else {showError(ppcER[2]);if (ppcTI) {clearTimeout(ppcTI);ppcTI = false;}}}
    else {
    showError(ppcER[1]);
    hideCalendar();}}
    function setCalendar(year,month) {
    if (year == null) {year = getFullYear(ppcNow);}
    if (month == null) {month = ppcNow.getMonth();setSelectList(year,month);}
    if (month == 1) {ppcML[1] = (isLeap(year)) ? 29 : 28;}
    ppcPtr.setYear(year);
    ppcPtr.setMonth(month);
    ppcPtr.setDate(1);
    updateContent();}
    function updateContent() {
    generateContent();
    if (ppcIE) {document.all['monthDays'].innerHTML = ppcCD;}
    else if (ppcNN) {
    with (document.layers['PopUpCalendar'].document.layers['monthDays'].document) {
    open("text/html");
    write("<html>\n<head>\n<title>DynDoc</title>\n</head>\n<body bgcolor=\"#FFFFFF\">\n");
    write(ppcCD);
    write("</body>\n</html>");
    close();}}
    else {showError(ppcER[0]);}
    ppcCD = ppcTT;}
    function generateContent() {
    var year = getFullYear(ppcPtr);
    var month = ppcPtr.getMonth();
    var date = 1;
    var day = ppcPtr.getDay();
    var len = ppcML[month];
    var bgr,cnt,tmp = "";
    var j,i = 0;
    for (j = 0; j < 7; ++j) {
    if (date > len) {break;}
    for (i = 0; i < 7; ++i) {
    bgr = ((i == 0)||(i == 6)) ? "#FFFFCC" : "#FFFFFF";
    if (((j == 0)&&(i < day))||(date > len)) {tmp += makeCell(bgr,year,month,0);}
    else {tmp += makeCell(bgr,year,month,date);++date;}}
    ppcCD += "<tr align=\"center\">\n" + tmp + "</tr>\n";tmp = "";}
    ppcCD += "</table>\n";}
    function makeCell(bgr,year,month,date) {
    var param = "\'"+year+"|"+month+"|"+date+"\'";
    var td1 = "<td width=\"20\" bgcolor=\""+bgr+"\" ";
    var td2 = (ppcIE) ? "</font></span></td>\n" : "</font></td>\n";
    var evt = "onMouseOver=\"this.style.backgroundColor=\'#FF0000\'\" onMouseOut=\"this.style.backgroundColor=\'"+bgr+"\'\" onMouseUp=\"selectDate("+param+")\" ";
    var ext = "<span Style=\"cursor: hand\">";
    var lck = "<span Style=\"cursor: default\">";
    var lnk = "";
    var cellValue = (date != 0) ? date+"" : " ";
    if ((ppcNow.getDate() == date)&&(ppcNow.getMonth() == month)&&(getFullYear(ppcNow) == year)) {
    cellValue = "<b>"+cellValue+"</b>";}
    var cellCode = "";
    if (date == 0) {
    if (ppcIE) {cellCode = td1+"Style=\"cursor: default\">"+lck+ppcFT+cellValue+td2;}
    else {cellCode = td1+">"+ppcFT+cellValue+td2;}}
    else {
    if (ppcIE) {cellCode = td1+evt+"Style=\"cursor: hand\">"+ext+ppcFT+cellValue+td2;}
    else {
    if (date < 10) {cellValue = " " + cellValue + " ";}
    cellCode = td1+">"+lnk+ppcFT+cellValue+td2;}}
    return cellCode;}
    function setSelectList(year,month) {
    var i = 0;
    var obj = null;
    if (ppcIE) {obj = document.ppcMonthList.sItem;}
    else if (ppcNN) {obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
    else {/* NOP */}
    while (i < 13) {
    obj.options.value = year + "|" + month;
    obj.options.text = year + " " + ppcMN[month];
    i++;
    month++;
    if (month == 12) {year++;month = 0;}}}
    function hideCalendar() {
    if (ppcIE) {document.all['PopUpCalendar'].style.visibility = "hidden";}
    else if (ppcNN) {document.layers['PopUpCalendar'].visibility = "hide";window.status = " ";}
    else {/* NOP */}
    ppcTI = false;
    setCalendar();
    ppcSV = null;
    if (ppcIE) {var obj = document.ppcMonthList.sItem;}
    else if (ppcNN) {var obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
    else {/* NOP */}
    obj.selectedIndex = 0;}
    function showError(message) {
    window.alert("[ PopUp Calendar ]\n\n" + message);}
    function isLeap(year) {
    if ((year%400==0)||((year%4==0)&&(year%100!=0))) {return true;}
    else {return false;}}
    function getFullYear(obj) {
    if (ppcNN) {return obj.getYear() + 1900;}
    else {return obj.getYear();}}
    function validDate(date) {
    var reply = true;
    if (ppcRL == null) {/* NOP */}
    else {
    var arr = ppcRL.split(":");
    var mode = arr[0];
    var arg = arr[1];
    var key = arr[2].charAt(0).toLowerCase();
    if (key != "d") {
    var day = ppcPtr.getDay();
    var orn = isEvenOrOdd(date);
    reply = (mode == "[^]") ? !((day == arg)&&((orn == key)||(key == "a"))) : ((day == arg)&&((orn == key)||(key == "a")));}
    else {reply = (mode == "[^]") ? (date != arg) : (date == arg);}}
    return reply;}
    function isEvenOrOdd(date) {
    if (date - 21 > 0) {return "e";}
    else if (date - 14 > 0) {return "o";}
    else if (date - 7 > 0) {return "e";}
    else {return "o";}}
    function dateFormat(year,month,date) {
    if (ppcDF == null) {ppcDF = "m/d/Y";}
    var day = ppcPtr.getDay();
    var crt = "";
    var str = "";
    var chars = ppcDF.length;
    for (var i = 0; i < chars; ++i) {
    crt = ppcDF.charAt(i);
    switch (crt) {
    case "M": str += ppcMN[month]; break;
    case "m": str += (month<9) ? ("0"+(++month)) : ++month; break;
    case "Y": str += year; break;
    case "y": str += year.substring(2); break;
    case "d": str += ((ppcDF.indexOf("m")!=-1)&&(date<10)) ? ("0"+date) : date; break;
    case "W": str += ppcWN[day]; break;
    default: str += crt;}}
    return unescape(str);}

  2. #2
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    Your code snippet is not really small - but it is not complete; so it will be difficult to help.

    Apart from that - do you know this one:
    http://javascript.internet.com/calen...te-picker.html
    ?? It can do what you want...

    Cheers - Pit

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12943 seconds
  • Memory Usage 2,859KB
  • Queries Executed 13 (?)
More Information
Template Usage (32):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates