Results 1 to 3 of 3

Thread: javascript injection

  1. #1
    Join Date
    Aug 2004
    70 klicks above the Do Lung bridge

    javascript injection

    Good morning. At work we have a system that tracks access to data so that people must re-request access to their data (to ensure people don't have access to data after thier requirement has ended).

    The system requires us to manually add in a start date and an end date but as the start date is always todays date and the end date is 99% of the time 6 months from that date, I decided to make a javascript injection bookmark that would automatically enter these dates for us. (I know that adding 6 months, taking into account different number of days in a month is difficult but even a rough date would save us time).

    What I am having trouble with is setting the date into a variable because it's in one line. Can anyone help with this? I have pasted what I have come up with so far but it doesn't work. If I take out the vars and put strings in it works fine.

    javascript:void(var now=new Date(),var end=now+(182*24*60*60*1000),document.forms[0].accessStart.value=now.format("dd/mm/yyyy"),document.forms[0].accessEnd.value=now.format("dd/mm/yyyy"))
    Last edited by Dopple; 05-29-2009 at 02:41 AM.

  2. #2
    Join Date
    Aug 2004
    70 klicks above the Do Lung bridge
    I have since noticed while searching through online code examples that the format function doesn't seem to work.
    I suppose my real question here is, how can I format a date (into dd/mm/yyy format) with one line of code. Is this possible or am I hoping for too much here?

  3. #3
    Join Date
    May 2003
    Between Baltimore and DC
    Just becuase it is on one line does not mean you can not use variables and such.

    Write it out as multiple lines. Make sure all your lines end with a semicolon. Than delete the line breaks and extra white space.

    Tech Author [Ajax In Action, JavaScript: Visual Blueprint] | twitter | linkedin | http://www.pascarello.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

Recent Articles