Advice on how to proceed w/Javascript/html/perl

Do I stay w/Javascript/HTML or switch to CGI?

Page 1 of 1

1 Replies - 1451 Views - Last Post: 24 August 2006 - 06:05 PM

#1 mhutch7714  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-August 06

Advice on how to proceed w/Javascript/html/perl

Posted 24 August 2006 - 04:50 AM

Hello,

I'm adding features to legacy code that involves fairly old material.

I've been around coding many years but not lots of Javascript/HTML (lately).

I have a need to fix a number of input variables in a .html prior to eventually going off to handle database requests w/perl/CGI.

Thus far, I've managed to handle all situations with "hidden" input types, but now I need to take the system date, count a number days in the future for one boundary and then count a number of days into the past for an other boudary, normalize these values and then feed them to the POST/Submit.

So, I wrote my future date routine (Plus45) in the javascript portion, but I am confused on how I might trigger it in order to substitute the date value into my ...proceedings? Below are some things I tried, to no avail.

Is there something I'm missing? Or would it just be better to perform all of this in perl/CGI?

Thanks,

mhutch

<input type=hidden value = "08092006" name=FUTURE_DAT >
<input type=hidden value = "java script:Plus45()" name=FUTURE_DAT>
<input type=hidden value = eval(Plus45); name=FUTURE_DAT >



Is This A Good Question/Topic? 0
  • +

Replies To: Advice on how to proceed w/Javascript/html/perl

#2 mhutch7714  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-August 06

Re: Advice on how to proceed w/Javascript/html/perl

Posted 24 August 2006 - 06:05 PM

Maybe my earlier post was too dignified?...

HELP! ANYONE!

I'm new enough to js that portions still seem like magic, but I have good coding skills.

I've written the routine to add 45 days to the current date but am a loss on how to trigger, or invoke the setting of the value when the form is submitted.

For example, as a test in the code below, I'm able to successfully manipulate settings via "hard-coding" the strings. Now I want to replace the hard-coded string with a value calculated from the system date.

Execution proceeds to a perl/CGI module after SUBMIT, so (I think) I need to set these values before "leaving" but I don't seem to be able to make that come about!

Any help/advice appreciated! I'm new enough to js that I could be "standing on top of the answer" and not realize it.

Thanks,






<input type= "hidden" name=OTHER_VALUE   value = "Y" >
<input type= "hidden" name=LOW_DAT  value = "08092006" >
<input type= "hidden" name=HIGH_DAT value = document.forms['acct'].elements['HIGH_DAT'].value >

function PlusDays() {
   var today = new Date();
   var fullyear = today.getFullYear();
   var ticksPerDay = (1000*60*60*24);
   var futureDateInMils = today.getTime() + 45 * ticksPerDay;
   var futuredate = new Date( futureDateInMils );

   str = ""+ (futuredate.getMonth()+1) + futuredate.getUTCDate() + futuredate.getFullYear()+ "</b><br>";
 
   var m = futuredate.getMonth() + 1;
   var d = futuredate.getUTCDate();
   var y = futuredate.getFullYear();

   m = "00" + m.toString();
   m = m.substr( m.length - 2, m.length );

   d = "00" + d.toString();
   d = d.substr( d.length - 2, d.length);

   var datestr = "" + m + d + y.toString();
   str = "str: " + "" + datestr + "<br>";
   return( datestr );
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1