in

Paul McFedries' Tech Tonic

Making the world a better place, one computer book at a time

Lingua Techna

Technology, language, and technical writing (plus some interesting stuff, too)

Information at Your Fingertips

My latest Technically Speaking column (called "Information at Your Fingertips") for IEEE Spectrum magazine is now online:

Published Mar 27 2009, 02:29 PM by Paul

Comments

 

PaoloSiani said:

Hi,

I'm trying to write a javascript funtion that would determine the number of days left in a specific month entered by the user. Basically the page will have two TBox where the user will enter the month and the date, than a button to call the final function that determine the days left in that month and will display it in another text box on the page. I just got started but I'm already stuck! I would appreciate any help.

here is my program so far (probably with some errors):

<html>

<head>

<title>Days Left in the Month</title>

<script type="text/javascript">

//Paolo Zoglianti

//This function will detrmine the total days in the month entered by the user

function daysInTheMonth(month)

{

var monthsDays;

monthsDays=parseInt(window.document.dayForm.monthTBox.value);

if (month==2){

monthsDays=28;

}

else {

if (month==4)||(usersMonth==6)||(month==8)|| (month==11){

monthsDays=30;

}

else {

monthsDays=31;

}

}

return monthsDays;

}

function determineDaysLeft();

{

var month;

var daysIn;

var daysLeft;

daysIn=parseInt(window.document.dayForm.dateTBox.value);

month=daysInTheMonth(month);

daysLeft = month - daysIn;

//display in text box

window.document.dayForm.daysLeftTBox=daysLeft;

}

</script>

</head>

<body>

<form name="dayForm">

Enter a month (1-12):

<input type="text" size="25" name="monthTBox"></input>

<br/>

Enter the date (1-31):

<input type="text" size="25" name="dateTBox"></input>

<br/>

<input type="button" value="How many days left?" onClick="determineDaysLeft();"></input>

<br/>

<hr/>

The number of days left in the month is:

<input type="text" size="25" name="daysLeftTBox"></input>

<br/>

</form>

</body>

</html>

Thanks!

May 6, 2009 1:44 PM
 

MMSproul said:

Hi Paul, My name is Matthew and I bought your book, Creating a Web Page...

I have a few questions thro... Do I need a business license ? Where do I find a Privacy Policy ?  My site is called www.yurpost.com  I haven't finished it yet, so I didn't up-load it, I still have a lot of work to do to it.... It's a site that everyone can post there artistic abilities and has lots of categories... I'm concerned about the copyright and legal stuff that I need to know.. Also, Can I use the graphics in the books CD for my web site ?? Hope you can help..... Thank you. Matt Sproul

wtre8@yahoo.com

November 15, 2009 2:50 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
Copyright © 2008 Logophilia Limited and Paul McFedries
Powered by Community Server (Commercial Edition), by Telligent Systems