41 users online (0 members and 41 guests)  

Thread: Help Please


  Results 1 to 3 of 3
  1. #1
    RonB.'s Avatar
    New User

    Status
    Offline
    Join Date
    May 2002
    Location
    Near Chicago
    Posts
    8

    Unhappy Help Please

    I have 2 date fields that have the ability to pop up a calendar to select a date and return it to the screen. It will return it to the field StartDate in the function restart. What I would like to happen is if the function newWindow is called return the date to the variable StartDate, and if the function newWindow2 is called return the date to the variable EndDate. I have included sections of code that I think are relivent.


    function restart() {
    document.data.StartDate.value = '' + year + '-' + padout(month - 0 + 1) + '-' + padout(day);
    mywindow.close();
    }

    function newWindow() {
    mywindow=open('cal.htm','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal.htm';
    if (mywindow.opener == null) mywindow.opener = self;
    }


    function newWindow2() {
    mywindow2=open('cal.htm','myname','resizable=no,width=350,height=270');
    mywindow2.location.href = 'cal.htm';
    if (mywindow2.opener == null) mywindow2.opener = self;
    }

    <form method=POST action="Update" name="data" onsubmit="return ValProjectMaint(this)">
    .
    .
    <input type=text name=StartDate size=10 maxlength=10 value="$(V_STRDT)">
    <INPUT TYPE="button" VALUE="Calendar" onClick="newWindow()">
    <input type=text name=EndDate size=10 maxlength=10 value="$(V_ENDDT)">
    <INPUT TYPE="button" VALUE="Calendar" onClick="newWindow2()">
    .
    .
    </form>



    This is the code for the calendar window
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript"><!--
    function Calendar(Month,Year) {
    var output = '';

    output += '<FORM NAME="Cal"><TABLE BGCOLOR="#EAE8C8" BORDER=0><TR><TD ALIGN=LEFT WIDTH=100%>';
    output += '<FONT COLOR="#993333" FACE="Verdana" SIZE=+1>' + names[Month] + ' ' + Year + '<\/FONT><\/TD><TD WIDTH=50% ALIGN=RIGHT>';
    output += '<SELECT NAME="Month" onChange="changeMonth();">';

    for (month=0; month<12; month++) {
    if (month == Month) output += '<OPTION VALUE="' + month + '" SELECTED>' + names[month] + '<\/OPTION>';
    else output += '<OPTION VALUE="' + month + '">' + names[month] + '<\/OPTION>';
    }

    output += '<\/SELECT><SELECT NAME="Year" onChange="changeYear();">';

    for (year=1900; year<2101; year++) {
    if (year == Year) output += '<OPTION VALUE="' + year + '" SELECTED>' + year + '<\/OPTION>';
    else output += '<OPTION VALUE="' + year + '">' + year + '<\/OPTION>';
    }

    output += '<\/SELECT><\/TD><\/TR><TR><TD ALIGN=CENTER COLSPAN=2>';

    firstDay = new Date(Year,Month,1);
    startDay = firstDay.getDay();

    if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
    days[1] = 29;
    else
    days[1] = 28;

    output += '<TABLE CALLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#C0C0C0"><TR>';

    for (i=0; i<7; i++)
    output += '<TD WIDTH=50 ALIGN=CENTER VALIGN=MIDDLE><FONT SIZE=-1 COLOR="#000000" FACE="Verdana"><B>' + dow[i] +'<\/B><\/FONT><\/TD>';

    output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';

    var column = 0;
    var lastMonth = Month - 1;
    if (lastMonth == -1) lastMonth = 11;

    for (i=0; i<startDay; i++, column++)
    output += '<TD WIDTH=50 HEIGHT=30><FONT SIZE=-1 COLOR="#808080" FACE="Verdana">' + (days[lastMonth]-startDay+i+1) + '<\/FONT><\/TD>';

    for (i=1; i<=days[Month]; i++, column++) {
    output += '<TD WIDTH=50 HEIGHT=30>' + '<A HREF="javascript:changeDay(' + i + ')"><FONT SIZE=-1 FACE="Verdana" COLOR="#008080">' + i + '<\/FONT><\/A>' +'<\/TD>';
    if (column == 6) {
    output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';
    column = -1;
    }
    }

    if (column > 0) {
    for (i=1; column<7; i++, column++)
    output += '<TD WIDTH=50 HEIGHT=30><FONT SIZE=-1 COLOR="#808080" FACE="Verdana">' + i + '<\/FONT><\/TD>';
    }

    output += '<\/TR><\/TABLE><\/FORM><\/TD><\/TR><\/TABLE>';

    return output;
    }

    function changeDay(day) {
    opener.day = day + '';
    opener.restart();
    self.close;
    }

    function changeMonth() {
    opener.month = document.Cal.Month.options[document.Cal.Month.selectedIndex].value + '';
    location.href = 'cal.htm';
    }

    function changeYear() {
    opener.year = document.Cal.Year.options[document.Cal.Year.selectedIndex].value + '';
    location.href = "cal.htm";
    }

    function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
    this[i] = makeArray0.arguments[i];
    }

    var names = new makeArray0('January','February','March','April','May','June','July','August','September','October','November','December');
    var days = new makeArray0(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var dow = new makeArray0('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
    //--></SCRIPT>
    </HEAD>

    <BODY BGCOLOR="#C0C0C0" TOPMARGIN=2 LEFTMARGIN=5>

    <P><CENTER>

    <SCRIPT LANGUAGE="JavaScript"><!--
    document.write(Calendar(opener.month,opener.year));
    //--></SCRIPT>

    </CENTER>
    </BODY>
    </HTML>

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hiya mate.

    Missed this post, which is a shame, 'cos its the most interesting one I have seen in a while.

    I kinda get what your problem is, but got a bit lost. Would you mind re-iterating, step-by-step the problem? thanks.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    I never saw this one either, not that I could have helped

    Suggestion:
    When choosing a title for your post avoid non descriptive such as "help!!!", "what in the world", "something is wrong!".

    Give your threads a short 3 or 4 word title relative to the nature of your post. The forums are optimized to draw very good rankings on individual threads, many threads get 100s of views from google traffic alone. Some of the best titles which have recieved tons more visitors are to the point, "background image" "drop down images" "New Window Size". Remember, every thread is displayed on the front page of AHFB, so it is important to create that link as effectivly as possible. The "Webmaster Ethics" forum is also fed to Stopscum.com a Geekvillage property.

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting