...

View Full Version : JavaScript question



franches
11-04-2004, 02:46 AM
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.



<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>

:confused:

fci
11-04-2004, 02:57 AM
I don't have IE so even if I could port it to JS I don't know if what I would be doing was right since you didn't post anything besides the vbscript. so in your next post be less vague.

fci
11-04-2004, 03:04 AM
also, from the looks of it you may be leaving out some key information.. such as any of the HTML related stuff. Post all the relevant code.

franches
11-04-2004, 03:41 AM
i have attached the page. i am doing the code to php and i'm using mysql. actually some of the codes are already converted but the vb scripts are my problems esp with the date. mydatabase is in yyyy-mm-dd format while the vb is mm/dd/yyyy so i would like to do the vb scripts to js so that i could manipulate the date. i am only familiar with programming but not good at it. i am on the process of learning it since i have a job to finish. i would really be thankful if you could help me. :)

ca_redwards
11-04-2004, 09:12 AM
i have attached the page. i am doing the code to php and i'm using mysql. actually some of the codes are already converted but the vb scripts are my problems esp with the date. mydatabase is in yyyy-mm-dd format while the vb is mm/dd/yyyy so i would like to do the vb scripts to js so that i could manipulate the date. i am only familiar with programming but not good at it. i am on the process of learning it since i have a job to finish. i would really be thankful if you could help me. :)

Here's an idea:


<html>
<head>
<script type="text/javascript" language="javascript">
Date.prototype.yyyymmdd=function(){
with(this){return [getFullYear(),(getMonth()<9?'0':'')+(1+getMonth()),(getDate()<10?'0':'')+getDate()].join('-')};
};
Date.prototype.mmddyyyy=function(){
with(this){return [(getMonth()<9?'0':'')+(1+getMonth()),(getDate()<10?'0':'')+getDate(),getFullYear()].join('/')};
};
</script>
</head>
<body onload="var d=new Date(prompt('date?',new Date()));alert(d.yyyymmdd());alert(d.mmddyyyy());">
</body>
</html>

By extending JavaScript's Date object, you can easily have both formats. In this example, whatever string you type in is handed to the Date constructor. Then the alerts simply display that date in each of those formats.

Does this help?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum