/    Sign up×
Community /Pin to ProfileBookmark

hi,
i would like to ask help from you js experts. I am trying to write this in js but i am having a hard time. i would really appreciate if you could help me with this.

[code=php]
<script language=”vbscript”>
<!–
filMonth = Month(Now)
filYear = Year(Date)

document.ViewForm.FilterMonth.value = filMonth
document.ViewForm.FilterYear.value = filYear
document.ViewForm.MonthChoice.value = filMonth
document.ViewForm.YearChoice.value = filYear
leapyearFilter = filYear mod 4
if document.ViewForm.MonthChoice.value = 2 then
if leapyearFilter = 0 then
dateEndDay = 29
elseif leapyearFilter > 0 then
dateEndDay = 28
end if
end if
if document.ViewForm.FilterYear.value = “2000” then
document.ViewForm.YearChoice.value = “00”
elseif document.ViewForm.FilterYear.value = “2001” then
document.ViewForm.YearChoice.value = “01”
elseif document.ViewForm.FilterYear.value = “2002” then
document.ViewForm.YearChoice.value = “02”
end if
if document.ViewForm.MonthChoice.value = “1” or + _
document.ViewForm.MonthChoice.value = “3” or + _
document.ViewForm.MonthChoice.value = “5” or + _
document.ViewForm.MonthChoice.value = “7” or + _
document.ViewForm.MonthChoice.value = “8” or + _
document.ViewForm.MonthChoice.value = “10” or + _
document.ViewForm.MonthChoice.value = “12” then
document.ViewForm.EDay.value = “31”
elseif document.ViewForm.MonthChoice.value = “2” then
document.ViewForm.EDay.value = dateEndDay
elseif document.ViewForm.MonthChoice.value = “4” or + _
document.ViewForm.MonthChoice.value = “6” or + _
document.ViewForm.MonthChoice.value = “9” or + _
document.ViewForm.MonthChoice.value = “11” then
document.ViewForm.EDay.value = “30”
end if
document.ViewForm.onStartYear.value = document.ViewForm.MonthChoice.value &”/1/”& document.ViewForm.YearChoice.value
document.ViewForm.onEndYear.value = document.ViewForm.MonthChoice.value &”/”& document.ViewForm.EDay.value &”/”& document.ViewForm.YearChoice.value
document.ViewForm.StartYear.value = document.ViewForm.MonthChoice.value &”/1/”& document.ViewForm.YearChoice.value
document.ViewForm.EndYear.value = document.ViewForm.MonthChoice.value &”/”& document.ViewForm.EDay.value &”/”& document.ViewForm.YearChoice.value
document.ViewForm.comStartYear.value = filMonth &”/1/”& filYear
document.ViewForm.comEndYear.value = filMonth &”/”& document.ViewForm.EDay.value &”/”& filYear

document.ViewForm.FinalDateNow.value = formatdatetime(document.ViewForm.DateNowValue.value,2)
document.ViewForm.FinalEndDateNow.value = formatdatetime(document.ViewForm.EndDateNowValue.value,2)
–>
</script> [/code]

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@CharlesNov 04.2004 — What [i]exactly[/i] is it that that piece of script is supposed to do? Which is to say, How will you know when the script is working?
Copy linkTweet thisAlerts:
@JPnycNov 04.2004 — I think it's just determining leap yr, but I don't see what is output.
Copy linkTweet thisAlerts:
@franchesauthorNov 04.2004 — i have attached the file which is an asp. i am doing this in php and mysql. i the vb codes are not working so i decided maybe it will be ok if i will rewrite the vbscripts into js. please examine the code.

[upl-file uuid=4b7d6ad8-4c63-4545-9d95-e996073c08f7 size=4kB]filteringview.zip[/upl-file]
Copy linkTweet thisAlerts:
@senshiNov 04.2004 — Do you want to determine if the date is a leap year? Thats a very simple logic test that will return true for a leap year and false for a non-leap year.

[CODE]
<script language="JavaScript" type="text/javascript">
document.write("Leap Years : ");
for(yrs=1960; yrs<2101; yrs++)
{
x= !(yrs % 4) ? true : false ;
if(x)
{
document.write("<br>"+yrs);
}
}

</script>[/CODE]


outputs a list of the years between 1960 & 2100 that are leap years. Looking at the code it appears that the bulk of it is to check that the year is YYYY and not YY and is also validating that the date for the month is valid, eg 28,29,30,31 day months.
Copy linkTweet thisAlerts:
@CharlesNov 04.2004 — [i]Originally posted by senshi [/i]

[B]Do you want to determine if the date is a leap year? Thats a very simple logic test that will return true for a leap year and false for a non-leap year.



[CODE]
<script language="JavaScript" type="text/javascript">
document.write("Leap Years : ");
for(yrs=1960; yrs<2101; yrs++)
{
x= !(yrs % 4) ? true : false ;
if(x)
{
document.write("<br>"+yrs);
}
}

</script>[/CODE]


outputs a list of the years between 1960 & 2100 that are leap years. Looking at the code it appears that the bulk of it is to check that the year is YYYY and not YY and is also validating that the date for the month is valid, eg 28,29,30,31 day months. [/B][/QUOTE]
Leap year is a bit more complicated than that, but just a bit more complicated:

[font=monospace]<script type="text/javascript">

<!--

function isLeapYear (year) {

if (isNaN (year)) return null;

if (year % 400 == 0) return true;

if (year % 100 == 0) return false;

if (year % 4 == 0) return true;

return false;

}

alert (isLeapYear (2100))

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@franchesauthorNov 05.2004 — thanks guys!
Copy linkTweet thisAlerts:
@senshiNov 05.2004 — [CODE]function leapYear(pV){
return (isNaN(pV)?null: (!(pV%400)?true: (!(pV%100)?false: (!(pV%4)?true:false))));
}
[/CODE]


Like I said it was a simple test, if you want something that will last more than 96 years then this ones for you.
×

Success!

Help @franches spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...