![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 9
Rep Power: 0
![]() |
Todays Date Problem
Ok for my website I'm trying to do a simple todays date box. and I need it to be like this:
<script type="text/javascript">
adate = new Date()
var badaydate = adate.getDay()
var numdate = adate.getDate()
var bamonthdate = adate.getMonth()
var yeardate = adate.getFullYear()
if (badate == 1) {
var daydate = Monday;
}
if (badate==0) {
var daydate = Sunday;
}
if (badate==2) {
var daydate = Tuesday;
}
if (badate==3) {
var daydate = Wednesday;
}
if (badate==4) {
var daydate = Thursday;
}
if (badate==5) {
var daydate = Friday;
}
if (badate==6) {
var daydate = Saturday;
}
if (bamonth==0) {
var monthdate = January;
}
if (bamonth==1) {
var monthdate = February;
}
if (bamonth==2) {
var monthdate = March;
}
if (bamonth==3) {
var monthdate = April;
}
if (bamonth==4) {
var monthdate = May;
}
if (bamonth==5) {
var monthdate = June;
}
if (bamonth==6) {
var monthdate = July;
}
if (bamonth==7) {
var monthdate = August;
}
if (bamonth==8) {
var monthdate = September;
}
if (bamonth==9) {
var monthdate = October;
}
if (bamonth==10) {
var monthdate = November;
}
if (bamonth==11) {
var monthdate = December;
}
document.write('test')
</script>Thanks |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Is that the whole thing? I mean, do you have a head and a body and all that?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2005
Posts: 9
Rep Power: 0
![]() |
Yes it does.. and it still didn't do anything..
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
This code woiks fer me. You can see it in action here.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date Thangy</title>
<script type="text/javascript">
adate = new Date()
var badaydate = adate.getDay()
var numdate = adate.getDate()
var bamonthdate = adate.getMonth()
var yeardate = adate.getFullYear()
if (badate == 1) {
var daydate = Monday;
}
if (badate==0) {
var daydate = Sunday;
}
if (badate==2) {
var daydate = Tuesday;
}
if (badate==3) {
var daydate = Wednesday;
}
if (badate==4) {
var daydate = Thursday;
}
if (badate==5) {
var daydate = Friday;
}
if (badate==6) {
var daydate = Saturday;
}
if (bamonth==0) {
var monthdate = January;
}
if (bamonth==1) {
var monthdate = February;
}
if (bamonth==2) {
var monthdate = March;
}
if (bamonth==3) {
var monthdate = April;
}
if (bamonth==4) {
var monthdate = May;
}
if (bamonth==5) {
var monthdate = June;
}
if (bamonth==6) {
var monthdate = July;
}
if (bamonth==7) {
var monthdate = August;
}
if (bamonth==8) {
var monthdate = September;
}
if (bamonth==9) {
var monthdate = October;
}
if (bamonth==10) {
var monthdate = November;
}
if (bamonth==11) {
var monthdate = December;
}
</script>
</head>
<body>
<script type="text/javascript">
document.write('test')
</script>
</body>
</html>
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2005
Posts: 9
Rep Power: 0
![]() |
Thanks. I figured the problem.. but forgot to post it I just had to quote the if variables. And I did it in a easier way using arrays:
<script type="text/javascript">
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthNames = new Array("January","February","March","April","May","June","July",
"August","September","October","November","December");
var dt = new Date();
var y = dt.getYear();
if (y < 1000) y +=1900;
document.write("<b>Todays date is:</b><br>"+dayNames[dt.getDay()] + ", " + monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y +"<br>"); |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
This might piss you off, but when you come to a forum like this and ask for free help, you should give some feedback if a profferred solution works or if you solve the problem yourself. I only invested about 15 minutes in this, but I'd rather not have done it at all if it was for naught. You didn't even apologize for being unthoughtful. That pisses ME off. Kiss my ass and get someone else to analyze your poor coding.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jan 2005
Posts: 9
Rep Power: 0
![]() |
Wow what is your problem. I'm sorry that I was busy but I had complications because I had to drive to the airport, so I COULDN'T reply, but then you already replied your SOLUTION. And yes I do thank you for the feedback. But you don't have to be a dick about this. I'm new, take it easy. Jesus christ.. you need to know the WHOLE story before you talk stuff that you DONT know.
|
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I don't give a rats if you had to go to the airport, you apparently got back and made your post. MY post came after YOUR second post, in which you had the opportunity to say, oh, I found the solution, but thanks for those offered. So you send me a PM as well as this post? Grow the fuck up and realize that when you get free help you should at least show SOME appreciation. Stick it up your ass, dumb fucker, your indignation cuts no water with me.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#9 |
|
Newbie
Join Date: Jan 2005
Posts: 9
Rep Power: 0
![]() |
Do you NOT see me saying thanks in the second post? I quote:
"Thanks. I figured the problem.. but forgot to post it I just had to quote the if variables. And I did it in a easier way using arrays:" so yea.. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|