Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JavaScript question

    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.

    PHP Code:
    <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> 

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Aug 2004
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Attached Files Attached Files

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Here's an idea for you...

    Quote Originally Posted by franches
    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:

    Code:
    <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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •