Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 12-30-2004, 05:44 AM   #1
It can never be too quiet
 
Stryker's Avatar
 
Join Date: May 2004
Location: Burlington, Ontario
Posts: 1,090
JavaScript to "getDate" compatible with Firefox

SORRY EVERYONE, MY MISTAKE.
I'VE FIXED THE ISSUE (I DIDN'T HAVE AN ID IN THE FIELDS THEMSELVES... )



Hi Folks,
I have a script that is calculating the date and time and then I am writing that date and time to a couple of hidden fields on the click of the a submit button to be sent to a cgiemail delivery. Here's the script:
HTML Code:
function setdatetime()
    {
        var thedate=new Date();

        var nday=thedate.getDay();
        var nmonth=thedate.getMonth();
        var ntoday=thedate.getDate();
        var nyear=thedate.getYear();

        if (nday==0) nday="Sunday";
        if (nday==1) nday="Monday";
        if (nday==2) nday="Tuesday";
        if (nday==3) nday="Wednesday";
        if (nday==4) nday="Thursday";
        if (nday==5) nday="Friday";
        if (nday==6) nday="Saturday";

        if (nmonth==0) nmonth="January";
        if (nmonth==1) nmonth="February";
        if (nmonth==2) nmonth="March";
        if (nmonth==3) nmonth="April";
        if (nmonth==4) nmonth="May";
        if (nmonth==5) nmonth="June";
        if (nmonth==6) nmonth="July";
        if (nmonth==7) nmonth="August";
        if (nmonth==8) nmonth="September";
        if (nmonth==9) nmonth="October";
        if (nmonth==10) nmonth="November";
        if (nmonth==11) nmonth="December";

        if (nyear<=99) nyear= "19"+nyear;

        if ((nyear>99) && (nyear<2000)) nyear+=1900;

        var thetime=new Date();

        var ampm="AM";
        var nhour=thetime.getHours();
        var nminute=thetime.getMinutes();

        if (nhour > 11) ampm = "PM";
        if (nhour > 12) nhour = nhour - 12;
        if (nhour == 0) nhour = 12;

document.getElementById('datestamp').value = (""+nday+", "+nmonth+" "+ntoday+", "+nyear);
document.getElementById('timestamp').value = (""+nhour+":"+nminute+" "+ampm);
    }
Most of this script is just formatting stuff so the date/time is recognizable when it's written and delivered. The problem is, this script is not writing the date and time when I complete and submit the form using Firefox or Netscape. Using all newest (or close to newest) versions of browsers (NS 7.2, IE 6.0, FF 1.0) but it only works with IE. Any ideas how I can get this to function with the other browsers? Is it something simple I've missed or should I use a completely different script?

Any help is greatly appreciated.
Thanks very much,
Stryker
__________________
Athlon XP 2800+ • Asus A7N8X (nVidia Nforce2) • Radeon 9600 Pro 256MB • 2x512MB KVR DDR PC3200 Dual Channel • 120GB Seagate 7200RPM 8MB • 160GB WD 7200RPM 8MB • Liteon DVD±RW DL • AOpen DVD±RW DL • Vantec Ion2 350W PSUSend me your picture for the Member Photo Gallery

Last edited by Stryker; 12-30-2004 at 06:16 AM. Reason: FIXED ISSUE ALREADY ! ! ! !
Stryker is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:15 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2