Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date object

Status
Not open for further replies.

grayliner

Programmer
Feb 2, 2002
10
US
ok so i'm trying to get the Day to show up, i know of the dateObj.getDay() and i have the array built to house the names of the days, but i can't get it to work, check out my code and let me know what is wrong with it

var days = new Array(7)
days[0] = "Sunday"
days[1] = "Monday"
days[2] = "Tuesday"
days[3] = "Wednesday"
days[4] = "Thursday"
days[5] = "Friday"
days[6] = "Saturday"

var seasons = new Array(4)
seasons[0] = "Fall"
seasons[1] = "Winter"
seasons[2] = "Spring"
seasons[3] = "Summer"

var browser = navigator.appName
var version = navigator.appVersion

var cute = new Date();
var hour = cute.getHours();
var minutes = cute.getMinutes();
if (hour > "12")
hours = (hour * 1) - 12;
else
hours = hour;
var time = hour + ":" + minutes;

function promptwindow() {

var promptwin = prompt("What is your name?","");

if ( (promptwin == null) || (promptwin == "") )
promptwin = "NO DATA"

newWindow=window.open("","","status,height=200,width=300");
newWindow.document.open();
newWindow.document.write('<html><body>');
newWindow.document.write(promptwin);
newWindow.document.write('<br><strong>Browser:</strong> ', browser);
newWindow.document.write('<br><strong>Version:</strong> ', version);
newWindow.document.write('<br><strong>Time:</strong> ', time);
newWindow.document.write(dateobj.getdays())
newWindow.document.write('</body></html>');
newWindow.document.close();
}




</script>
<title>right</title>
<meta name=&quot;author&quot; content=&quot;David Mudder&quot; />
<link rev=&quot;made&quot; title=&quot;author's e-mail&quot; href=&quot;mailto:klay2@juno.com&quot; />
</head>

<body bgcolor=&quot;#33CC00&quot; text=&quot;#000000&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>
Name:
<input type=&quot;text&quot; name=&quot;textfield&quot; />
<br />
Address:
<input type=&quot;text&quot; name=&quot;textfield2&quot; />

<br />
E-mail:
<input type=&quot;text&quot; name=&quot;textfield3&quot; />
<br />
Male:
<input type=&quot;radio&quot; name=&quot;radiobutton&quot; value=&quot;radiobutton&quot; checked />
<br />
Female:
<input type=&quot;radio&quot; name=&quot;radiobutton&quot; value=&quot;radiobutton&quot; />
<br />
Unsure:
<input type=&quot;radio&quot; name=&quot;radiobutton&quot; value=&quot;radiobutton&quot; />

<p>Free Magazine:
<input type=&quot;checkbox&quot; name=&quot;checkbox2&quot; value=&quot;checkbox&quot; />
<br />
Free Book:
<input type=&quot;checkbox&quot; name=&quot;checkbox3&quot; value=&quot;checkbox&quot; />
<br />
Free Pamphlet:
<input type=&quot;checkbox&quot; name=&quot;checkbox&quot; value=&quot;checkbox&quot; />
</p>

<input type=&quot;button&quot; name=&quot;button1&quot; value=&quot;Prompt&quot; onClick=&quot;promptwindow()&quot; />
<input type=&quot;button&quot; name=&quot;button2&quot; value=&quot;button2&quot; />
<input type=&quot;button&quot; name=&quot;button3&quot; value=&quot;button3&quot; />
<br />
<br />
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; />
</form>
</body>
</html>
 
Do you ever read your error messages?
on the line:
Code:
newWindow.document.write(dateobj.getdays())
Code:
dateobj
is undefined! That means that you never created an object called dateobj. Remember that the object you created for the date is
Code:
cute
.

Oh, and take note: There are no functions
Code:
getdays()
or
Code:
getDays()
for a Date object. There is, however, a
Code:
getDate()
function.
 
i dont get error messages when i program in IE6.0 The pen is mightier than the sword.
 
hmm... I'm using IE 6.0.2600.0000
And I got an error message.

And yes, indeed, that error message is supposed to be there;
Code:
dateobj
was never defined.

Maybe you have IE set not to inform you for every JavaScript error (under Tools >> Internet Options >> Advanced, there should be a checkbox labeled: Display a notification about every script error. I have this checked whenever I code or test code)
 
o kewl, i didnt realize that till now.

thanks! The pen is mightier than the sword.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top