Solved

Instead of displaying as the first day of the year in an entry field it displays as the second

Posted on 2003-10-25
18
231 Views
Last Modified: 2007-12-19
Hi:

I have a calendar html page that has a javascript as well. It has a drop down button that gives you five choices. Today, yesterday, Week to Date, Month to Date and Year
to Date. Everything works except for the Year to Date. When it is chosen rather than the beginning date field being filled with 1 January 2003 it is filled with 2 January 2003 and the ending date is filled with today's date as expected.

Any ideas where I am going wrong?

Chuck

//get the year to date
if(document.layers){
var thisDateIH = "1 January, "+(agdate.getYear()+1900);
}else{
var thisDateIH = "1 January, "+(agdate.getYear());
}
0
Comment
Question by:TrueBlue
  • 11
  • 7
18 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9621637
Hi,


  I get jan 1 ==> nn4.7 & ie6.0

 agdate = new Date()
 alert("1 January, "+(agdate.getYear()));

if the above is not your actual code & you are filling in the '1' from a selection list, the only thing I can think of:  javascript starts counting with 0, not 1 -- so if you are passing the selectedIndex, it might be 0 and not 1.

Vinny
0
 

Author Comment

by:TrueBlue
ID: 9621701
Hi!
Apparently it is the 1900 that is adding the extra day. I am not sure why the original programmer had this, but he also had it for the week to date:
//get the week to date
var minos=agdate.getDay();
var tiker=(agdate.getTime()-(LTweak[minos]*ixday));
var fuse = new Date(tiker);
if(document.layers){
var yeartrap = fuse.getYear() + 1900;
}else{
var yeartrap = fuse.getYear();
}

Would this have to do with leap year maybe?

Chuck
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9622350

the 1900 is for y2k coding,
I doubt if the problem has to do with leap years
in all likelihood the problem is here
var minos=agdate.getDay();
or here:
var tiker=(agdate.getTime()-(LTweak[minos]*ixday));

the first line produces a number relative to the 'Day of Week' -- Sun (0) to Sat (6)


Vinny
0
 

Author Comment

by:TrueBlue
ID: 9622397
Hi Vinny:

I was just showing the code for the week to date as an example to find out what the 1900 is for. It works fine. As I said earlier, only the year to date code is broken.

It starts on 2 January 2003. If I remove the 1900 it works fine, but since it is a Y2K fix. I guess I need to find a work around and leave it in.

Any ideas?

Chuck
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9622466
could you post all of the pertinent code?   Tweak, etc.

Vinny
0
 

Author Comment

by:TrueBlue
ID: 9622632
Hi Vinny:

Here is the whole file:

Chuck

<html>
<head>
      <title>Date Range Selector</title>
      
<link rel="stylesheet" href="daughter_window.css" type="text/css">
<!-- BEGIN THE JAVASCRIPT BONANZA! -->
<script language="JavaScript">
<!--
//////////////////////////////////////////////////////////////
//////////   USER CONFIGURABLE VARIABLES      ////////////////
//////////////////////////////////////////////////////////////

// you can set this to false if you don't want people to be able to select dates in the past
// you will need to set this to the same values in the calendarCore.html file
var deadhistory = '1 January, 2003';

// if you leave this as false, the furthest in the future they can select dates is the
// number of years specified in the 'futureNum' variable below it.
// You can also set this to a readable date (i.e. '15 March, 2003').
// you will need to set these to the same values in the calendarCore.html file

var deadfuture = false;
var futureNum = 1;
///////////////////////////////////////////////////////////////
// change this to whatever year you want the script to display
// as the farthest year back in the pull down menu
var startyr = 2003;

///////////////////////////////////////////////////////////////
// change this to whatever script or form handler you wish to  
// submit the dates to
var frmAction = 'excelwebsignalsbystoresrc.asp';


//////////////////////////////////////////////////////////////
//////////   END USER CONFIGURABLE VARIABLES      ////////////
//////////                                        ////////////
//////////               WARNING!!!!              ////////////
//////////   BEYOND HERE YOU ARE ON YOUR OWN      ////////////
//////////////////////////////////////////////////////////////

var ixday = (24*60*60*1000);
var liv = false;
var bee = false;
//////////////////////////////////////////////////////////////////////////////////////////////////////

if(deadhistory){
var choke = Date.parse(deadhistory);// make choke = to a millisecond date format passed from the server
}else{
var iDate = new Date()
var choke = (iDate.getTime() - ixday);
}
if(deadfuture){
var shank = Date.parse(deadfuture);//make shank = to a millisecond date format passed from the server
}else{
var eDate = new Date()
var shank = (eDate.getTime() + (ixday*365*futureNum));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// date variables
var mdy = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
var mdyShort = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28);
var mdyShortLeap = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
var mdyLong = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
var myLeap = new Array(2000,2004,2008,2012,2016,2020,2024,2028,2032,2036,2040,2044,2052,2056,2060,2064);
var myMonths = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var myDaze = new Array(mdyLong,mdyShortLeap,mdyShort,mdy);
var showyrs = 30;

//Set the date from the calendar and compute the range values
function fromCal(){
var qwz = 0;
if (document.db.doit.value != ""){
      var gils=document.db.holdme.value;
      var fiesta = new Date(gils);
      var bamm = fiesta.getTime();
      var boozle=valiDate(bamm);
                  if(boozle){
                  JV_dateMaker(fiesta,document.db.whichone.value-1);
                  }else{
                  alert('Out of acceptable parameter range.\nPlease select a different Date');
                  }
            while(document.db.elements[qwz]){
            document.db.elements[qwz].value="";
            qwz++;
                                                            }
                                                }
}
////////////////////////////////////////////////////////////////////////////////
// find out the date ---
// insert a millisecond date format passed from the server
// as an argument to Date(milliseconds) for production
ud = new Date();// like this---> ud = new Date(milliseconds);
////////////////////////////////////////////////////////////////////////////////
// change the date to milliseconds
chud = ud.getTime();
//plain vanilla window opener
function showCal(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// calculate the unix milliseconds covered by the range value
function dateCalc(i,op)
            {
if(op==0){
var kink = chud;
sbd = (kink + (i*24*60*60*1000));
jnd = new Date(sbd);
bee = valiDate(jnd)
ind = new Date(kink);
liv = valiDate(ind);
}
if(op==1){
var kink = chud;
sbd = (kink - (i*24*60*60*1000));
ind = new Date(sbd);
bee = valiDate(ind)
jnd = new Date(kink);
liv = valiDate(jnd);
}
            }
//dates get changed based on date pulldowns

function changeSelect(sm,ile){
document.changer.elements[5].checked=true;
var its = sm.form.elements[0].options[sm.form.elements[0].selectedIndex].value + ' ';
var mond = sm.form.elements[1].options[sm.form.elements[1].selectedIndex].text + ' ';
var dey = sm.form.elements[2].options[sm.form.elements[2].selectedIndex].value + ' ';
var blues = mond + ' ' +its+ ', '+dey;
var shin = Date.parse(blues);
var offSetter = '';
if(document.changer.other.value==''){offSetter=document.changer.tink.options[document.changer.tink.selectedIndex].value;}
else{offSetter=document.changer.other.value;}
if(sm.form.name=='ranger'){
var knee = new Date(shin);
var tib = knee.getTime();
var rnu = valiDate(tib);
if(rnu){
JV_dateMaker(knee,0);
document.realForm.elements[0].value=tib;
}
else{
document.realForm.elements[0].value=tib;
}
}
if(sm.form.name=='bob'){
var knee = new Date(shin);
var tib = knee.getTime();
var bnu = valiDate(tib);
if(bnu){
JV_dateMaker(knee,1);
document.realForm.elements[1].value=tib;
}
else{
document.realForm.elements[1].value=tib;
}
}
}
//compare to acceptable date range
function valiDate(pelv){
if(pelv<=choke || pelv>=shank){return false;}
else{
return true;
}
}

function changeIt(sel){
document.changer.elements[0].checked=true;
var tenser=0;
init(0,0);
if(document.changer.elements[0].checked==true){
//if(sel.form.elements[1].checked == true){tenser=sel.form.elements[1].value}
//if(sel.form.elements[2].checked == true){tenser=sel.form.elements[2].value}
if(sel.form.elements[4].value != ''){
if(sel.form.elements[4].value<0){
      tenser=0;
      }else{
      tenser=1;
      }
init(Math.abs(sel.form.elements[4].value), tenser);
}
else{
if(sel.form.tink.options[sel.form.tink.selectedIndex].value < 0){
      tenser=1;
      }else{
      tenser=0;
      }
init(Math.abs(sel.form.tink.options[sel.form.tink.selectedIndex].value), tenser);
}
}else{
alert('Please Check the "Pick Standard Date Range" radio button if you wish to use this feature');
      }
}

function JV_dateMaker(sd,id){
//takes a date in millisecond format and builds a range selector element set
var ly = 0;//decide if it is a leapyear or not
var mll = myLeap.length;
if(document.layers){var yr = sd.getYear()+1900;}
if(document.all){var yr = sd.getYear();}
for(y=0;y<mll;y++){
if(yr == myLeap[y]){ ly = 1;}
}
//decide which option set to populate dates with.
var modaze = "";
      if(sd.getMonth() == 1 && ly == 1){
                                    modaze = 1;
                                    }
      else if(sd.getMonth() == 1 && ly == 0){
                                    modaze = 2;
                                    }
      else if(sd.getMonth() == (3 || 5 || 8 || 10)){
                                    modaze = 3;
                                    }
                              else{
                                    modaze = 0;
                                    }
var vint = myDaze[modaze];
//build out the month options
document.ranger.ma.length = myMonths.length;
document.bob.mb.length = myMonths.length;
for(iggy=0;iggy<myMonths.length;iggy++){
document.ranger.ma.options[iggy].text = myMonths[iggy];
document.ranger.ma.options[iggy].value = iggy;
document.bob.mb.options[iggy].text = myMonths[iggy];
document.bob.mb.options[iggy].value = iggy;
}
//buildout the year options starting with last year
//selecting specified year, and showing 5 more
if(id==0){
for(q=0;q<vint.length;q++){
document.ranger.da.options.length = vint.length;
// build out the date option for the first date selector
document.ranger.da.options[q].text = vint[q];
document.ranger.da.options[q].value = vint[q];
if(q==(sd.getDate() - 1)){
                                          document.ranger.da.selectedIndex = q;
                                          }
                                    }
                  document.ranger.ma.selectedIndex = sd.getMonth();
//set the year options
var rip = startyr;
document.ranger.ya.options.length = showyrs;
for(wink=0;wink<showyrs;wink++){
document.ranger.ya.options[wink].text = wink + rip;
document.ranger.ya.options[wink].value = wink + rip;
}
//set the year
for(laz=0;laz<showyrs;laz++){
if(document.layers){var miyr=(sd.getYear() + 1900);}
if(document.all){var miyr=sd.getYear();}
if(document.ranger.ya.options[laz].value==miyr){
                                          document.ranger.ya.selectedIndex = laz;
                                          }            
}
document.realForm.elements[0].value=sd.getTime();
                              }
if(id==1){
document.bob.db.options.length = vint.length;
// build out the date option for the second date selector
for(q=0;q<vint.length;q++){
document.bob.db.options[q].text = vint[q];
document.bob.db.options[q].value = vint[q];
if(q==(sd.getDate() - 1)){
                                          document.bob.db.selectedIndex = q;
                                          }                                          
                                    }
// set the month
                        document.bob.mb.selectedIndex = sd.getMonth();
//set the year options
var van = startyr;
document.bob.yb.options.length = showyrs;
for(gogh=0;gogh<showyrs;gogh++){
document.bob.yb.options[gogh].text = gogh + van;
document.bob.yb.options[gogh].value = gogh + van;
}
//set the year
for(laz=0;laz<showyrs;laz++){
if(document.layers){var niyr=(sd.getYear() + 1900);}
if(document.all){var niyr=sd.getYear();}
if(document.bob.yb.options[laz].value==niyr){
                                          document.bob.yb.selectedIndex = laz;
                                          }            
}
document.realForm.elements[1].value=sd.getTime();
                              }
}

function init(dif,ichop){
dateCalc(dif,ichop);
if(liv && bee){
liv=false;
bee=false;
JV_dateMaker(ind,0);
JV_dateMaker(jnd,1);
}else{
liv=false;
bee=false;
alert('Out of acceptable parameter range.\nPlease select a shorter\n range or different Date');
}
}

function setupHiddenForm(bx){
//pput in a few values get set for the new window to use
document.changer.elements[5].checked=true;
document.db.whichone.value=bx ;
document.db.forwards.value=shank ;
document.db.backward.value=choke ;
if(document.changer.other.value==""){
var drange = document.changer.tink.options[document.changer.elements[1].selectedIndex].value;
}else{
var drange = document.changer.other.value;
}
document.db.howfar.value=drange;
self.name = 'winop';
showCal('calframe.html','calzone','width=170,height=137');
}

function clearOther(ibis){ibis.form.other.value="";}

function getThisToDate(aDate,wmy){
// Takes a date in miliseconds as the first arguement,
// and wheter it's a week, month or year that you would
// want to calculate. 0=week 1=month 2=year
// returns a start date
var agdate = new Date(aDate);
//because we want to start the week on monday...
var LTweak = new Array(6,0,1,2,3,4,5);
var timebomb=0;
if(wmy==0){
//get the week to date
var minos=agdate.getDay();
var tiker=(agdate.getTime()-(LTweak[minos]*ixday));
var fuse = new Date(tiker);
if(document.layers){
var yeartrap = fuse.getYear() + 1900;
}else{
var yeartrap = fuse.getYear();
}
var C4 = fuse.getDate() + " " + myMonths[fuse.getMonth()] + ", " +  yeartrap
var ignyt=Date.parse(C4);
var timebomb = ((fuse.getTime() - agdate.getTime())/ixday);
}
else if(wmy==1){
//get the month to date
var minos=agdate.getDate();
var tiker=(agdate.getTime()-(minos*ixday));
var fuse = new Date(tiker);
var timebomb=1+((fuse.getTime()- agdate.getTime())/ixday);
}
else if(wmy==2){
//get the year to date
if(document.layers){
//var thisDateIH = "1 January, "+(agdate.getYear()+1900);
var thisDateIH = "1 January, "+(agdate.getYear());
}else{
var thisDateIH = "1 January, "+(agdate.getYear());
}
var minos = Date.parse(thisDateIH);
var fuse = new Date(minos);
fuse.setHours(agdate.getHours());
fuse.setMinutes(agdate.getMinutes());
fuse.setSeconds(agdate.getSeconds());
var wire=((fuse.getTime()- agdate.getTime())/ixday);
var trigger=wire.toString();
var C4 = trigger.split('.');
var timebomb = C4[0];
}
return timebomb;
}

function valiData(rf){
hot = true;
errormsg = 'The Following Errors were found:\n\n';

if(rf.elements[0].value<choke){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected goes back beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[0].value>shank){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected goes forward beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[1].value<choke){
      hot=false
      errormsg= errormsg + 'The End Date you have selected goes back beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[1].value>shank){
      hot=false
      errormsg= errormsg + 'The End Date you have selected goes forward beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[0].value> rf.elements[1].value){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected is later than your End date,\n please adjust your selection\n\n';
      }




if(hot){
rf.action=frmAction;
rf.submit();
}else{
alert(errormsg);
}
}
// end valiData


function setUpForms(){
//initialize the range list
document.changer.elements[1].options[2].value=getThisToDate(ud.getTime(),0);
document.changer.elements[1].options[3].value=getThisToDate(ud.getTime(),1);
document.changer.elements[1].options[4].value=getThisToDate(ud.getTime(),2);

//document.reportz.graph.options.selectedIndex=oldGraph;
init(0,0);
}//end setUpForms
function setFreq(igna){
document.realForm.elements[2].value=igna.form.elements[0].options[igna.form.elements[0].selectedIndex].value;

}



//-->
    </script>
<!-- END THE JAVASCRIPT BONANZA! -->
<meta name="Microsoft Theme" content="st-pvlogoblue 011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body marginwidth="0" marginheight="0" topMargin="0" leftMargin="0" onload="setUpForms()">
<div align="center">

<!-- BEGIN HEADER TABLE -->
<table class="rptMain" width="100%" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td class="rptHd">&nbsp;Date Range Selector</td>
    <td class="rptHd" align="right"><a href="javascript:self.close();"><img src="img/icon_close.gif" alt="Close" width="15" height="15" border="0"></a></td>
  </tr>
</table>
<!-- END HEADER TABLE -->

<!-- BEGIN INPUT TABLE -->
<table border="0" cellspacing="5" cellpadding="0" width="100%">
  <tr align="center">
    <td align="left" class="blackBld" colspan="4" nowrap>
      &nbsp;</td>
  </tr>
  <tr align="left" valign="top">
    <td class="rptDiv" colspan="4" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
  <tr><form method=post action="" name="changer">
      <!-- BEGIN FIRST PART OF FORM (optional, you can delete this ) -->       

    <td align="left" class="grayBld" nowrap>Date range:</td>
    <td align="left" class="grayBld" nowrap><input type="radio" name="auotrange" value="1" onClick="reset(this.form);init(0,0)" checked></td>
    <td align="left" class="grayBld" colspan="2" nowrap>Pick a standard date range
     
<select name="tink" onChange="changeIt(this);clearOther(this)">
            <option selected value="0">Today</option>
            <option value="-1">Yesterday</option>
            <option value="-2">Week to Date</option>
            <option value="-13">Month to Date</option>
            <option value="-44">Year to Date</option>
            <option></option>
</select>
      <!-- END FIRST PART OF FORM (optional, you can delete this ) -->       

<input type="hidden" name="direction" value="1">
<!-- forgot what this is for so leave it for now -->
<input type="hidden" name="dunkle" value="0">
<input type="hidden" size="4" maxlength="4" name="other" value="">
    </td>
  </tr>
  <tr align="left" valign="top">
    <td align="left" class="grayBld" nowrap></td>
    <td class="rptDiv" colspan="3" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
      <!-- BEGIN SECOND RADIO BUTTON(optional, you can delete this ) -->       

  <tr>
    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap>
      
      <input type="radio" name="auotrange" value="0"></td>
    <td align="left" class="grayBld" colspan="2" nowrap>Set your own </td></form>
  </tr>
      <!-- END SECOND RADIO BUTTON(optional, you can delete this ) -->       

  <tr><form method=post action="" name="ranger">

    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap></td>
    <td align="right" class="grayBld" nowrap>Start date</td>
    <td align="left" class="grayBld" nowrap>
                  <select name="da" onChange="changeSelect(this,0)";>
                        <option>__</option>
                        <option>__</option>
                        <option>__</option>
                        <option>__</option>
                  </select>
                  <select name="ma" onChange="changeSelect(this,0)">
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>

                  </select>
                  <select name="ya" onChange="changeSelect(this,0)">
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                  </select>
      <a href="#" onClick="setupHiddenForm(1)"><img src="img/btn/use_cal.gif" width="71" height="16" border="0"></a>
    </td></form>
  </tr>
  <tr><form method=post action="" name="bob">
    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap></td>
    <td align="right" class="grayBld" nowrap>End date</td>
    <td align="left" class="grayBld" nowrap>
            <select name="db" onChange="changeSelect(this,0)">
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
            </select>
            <select name="mb" onChange="changeSelect(this,0)">
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
            </select>
            <select name="yb" onChange="changeSelect(this,0)">
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
            </select>
      <a href="#" onClick="setupHiddenForm(2)"><img src="img/btn/use_cal.gif" width="71" height="16" border="0"></a>
    </td></form>
  </tr>
  <tr align="left" valign="top">
    <td class="rptDiv" colspan="4" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
 
  </table>
<!-- END INPUT TABLE-->

<!-- BEGIN ACTION BUTTONS TABLE -->
<table border="0" cellspacing="5" cellpadding="0" width="100%">
  <tr align="left" valign="top">
    <td class="rptDiv" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
  <tr align="left" valign="top">
    <td nowrap>
<center>     <a href="#" onClick="valiData(document.realForm)"><img src="img/btn/change_paramsOK.gif" width="50" height="16" border="0"></a>
     <a href="#" onClick="self.close()"><img src="img/btn/change_paramsCANCEL.gif" width="50" height="16" border="0"></a></center>
    </td>
  </tr>
</table>
<!-- END ACTION BUTTONS TABLE-->

</div>
<!-- HOLDS THE DATA TO BE USED WITH CALENDARS -->

<form method=post name="db" action="javascript:fromCal()">
<input type="hidden" name="whichone" value="">
<input type="hidden" name="forwards" value="">
<input type="hidden" name="backward" value="">
<input type="hidden" name="doit" value="">
<input type="hidden" name="holdme" value="">
<input type="hidden" name="howfar" value="">
<input type="hidden" name="whereis" value="">
</form>

<!--

HOLDS THE REAL DATA TO BE SUBMITTED FROM THIS FORM
APPEND ANY FEILDS YOU NEED TO ADD TO THIS FORM
      
 -->

<form method=post name="realForm" action="">
<!-- YOU'LL WANT TO MAKE THIS STUFF HIDDEN IN PRODUCTION OF COURSE. -->
<input type="hidden" name="wstartDate" value="" size="20">
<input type="hidden" name="endDate" value="" size="20">
<input type="hidden" NAME="a" VALUE="<%=CSTR(Request.QueryString("ID1"))%>"><br/>

</form>
</body>
</html>
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9624333
Hi Chuck,

  I just wanted to keep you posted -- the Jets lost 24-17, so I'm a little :(

  Insofar as your code -- I've given it a cursory look and decided -- it was definitely written by someone who tried to make himself indispensible.  It's going to take me a little bit to figure out what and where he is doing and why, but it can be fixed -- after I get over my football blues.

  Vinny
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 250 total points
ID: 9624512
Hi,

  Depression is a weird thing -- a little yelling, a little ice cream, some drinks, and some really deliberately obtuse code to straighten out -- this should fix it:

function changeIt(selObj, formObj)
{
   var tenser = 0;
   var selVal = selObj.options[selObj.selectedIndex].value;
   var otherVal = formObj.other.value;
   init(0,0);
   if(formObj.elements[0].checked==true)
   {
     if(otherVal != '')
     {
        tenser = (val < 0) ? 0 : 1;
        init(Math.abs(otherVal), tenser);
     }
     else
     {
      tenser = (selVal < 0) ? 1 : 0;
      init(Math.abs(selVal), tenser);
     }
    }
    else
    {
alert('Please Check the "Pick Standard Date Range" radio button if you wish to use this feature');
     }
}

and the function call:

<select name="tink" onChange="changeIt(this, this.form);clearOther(this)">

You really should get someone to turn that garbage into some semblance of real code with meaningful names and then chuck the rest of it in the trash bin

this, for example,
if(sel.form.tink.options[sel.form.tink.selectedIndex].value < 0){
is the same as this:
if(sel.options[sel.selectedIndex].value < 0){

all sel.form.tink does is start with a reference point then go up and back down to itself.

Vinny
0
 

Author Comment

by:TrueBlue
ID: 9630403
Hi Vinny!

I incorporated your suggestions into the code.

This is what I got:

Line 171 expected ";"
init(0,0);

Line 429 Object Expected
<div align="center">

Line 463 Object Expected
</select>

Do you happen to know of third party asp (classic) developer that has this kind of functionality?
I can email you the file if you would like?

Thank you in advance.

Chuck
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9630437
Hi Chuck,

   did you replace the entire function with the above? and replace the selection list onchange?
(from what I remember, it ran properly last night.)  repost the code as it stands now.
   re: emailing me with the file -- I accept emails from paying clients only (if interested, you can find my email add by clicking on my name above)

 re 3rd party asp: nope.  Anyway, you want javascript; asp requires a server call -- loss of time

Vinny

0
 

Author Comment

by:TrueBlue
ID: 9630600
Hi Vinny!

Here is the calendar.html file with your suggestions.

Thank you again.

Chuck

<html>
<head>
      <title>Date Range Selector</title>
      
<link rel="stylesheet" href="daughter_window.css" type="text/css">
<!-- BEGIN THE JAVASCRIPT BONANZA! -->
<script language="JavaScript">
<!--
//////////////////////////////////////////////////////////////
//////////   USER CONFIGURABLE VARIABLES      ////////////////
//////////////////////////////////////////////////////////////

// you can set this to false if you don't want people to be able to select dates in the past
// you will need to set this to the same values in the calendarCore.html file
var deadhistory = '1 January, 2003';

// if you leave this as false, the furthest in the future they can select dates is the
// number of years specified in the 'futureNum' variable below it.
// You can also set this to a readable date (i.e. '15 March, 2003').
// you will need to set these to the same values in the calendarCore.html file

var deadfuture = false;
var futureNum = 1;
///////////////////////////////////////////////////////////////
// change this to whatever year you want the script to display
// as the farthest year back in the pull down menu
var startyr = 2003;

///////////////////////////////////////////////////////////////
// change this to whatever script or form handler you wish to  
// submit the dates to
var frmAction = 'excelwebsignalsbystoresrc.asp';


//////////////////////////////////////////////////////////////
//////////   END USER CONFIGURABLE VARIABLES      ////////////
//////////                                        ////////////
//////////               WARNING!!!!              ////////////
//////////   BEYOND HERE YOU ARE ON YOUR OWN      ////////////
//////////////////////////////////////////////////////////////

var ixday = (24*60*60*1000);
var liv = false;
var bee = false;
//////////////////////////////////////////////////////////////////////////////////////////////////////

if(deadhistory){
var choke = Date.parse(deadhistory);// make choke = to a millisecond date format passed from the server
}else{
var iDate = new Date()
var choke = (iDate.getTime() - ixday);
}
if(deadfuture){
var shank = Date.parse(deadfuture);//make shank = to a millisecond date format passed from the server
}else{
var eDate = new Date()
var shank = (eDate.getTime() + (ixday*365*futureNum));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// date variables
var mdy = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
var mdyShort = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28);
var mdyShortLeap = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
var mdyLong = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
var myLeap = new Array(2000,2004,2008,2012,2016,2020,2024,2028,2032,2036,2040,2044,2052,2056,2060,2064);
var myMonths = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var myDaze = new Array(mdyLong,mdyShortLeap,mdyShort,mdy);
var showyrs = 30;

//Set the date from the calendar and compute the range values
function fromCal(){
var qwz = 0;
if (document.db.doit.value != ""){
      var gils=document.db.holdme.value;
      var fiesta = new Date(gils);
      var bamm = fiesta.getTime();
      var boozle=valiDate(bamm);
                  if(boozle){
                  JV_dateMaker(fiesta,document.db.whichone.value-1);
                  }else{
                  alert('Out of acceptable parameter range.\nPlease select a different Date');
                  }
            while(document.db.elements[qwz]){
            document.db.elements[qwz].value="";
            qwz++;
                                                            }
                                                }
}
////////////////////////////////////////////////////////////////////////////////
// find out the date ---
// insert a millisecond date format passed from the server
// as an argument to Date(milliseconds) for production
ud = new Date();// like this---> ud = new Date(milliseconds);
////////////////////////////////////////////////////////////////////////////////
// change the date to milliseconds
chud = ud.getTime();
//plain vanilla window opener
function showCal(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// calculate the unix milliseconds covered by the range value
function dateCalc(i,op)
            {
if(op==0){
var kink = chud;
sbd = (kink + (i*24*60*60*1000));
jnd = new Date(sbd);
bee = valiDate(jnd)
ind = new Date(kink);
liv = valiDate(ind);
}
if(op==1){
var kink = chud;
sbd = (kink - (i*24*60*60*1000));
ind = new Date(sbd);
bee = valiDate(ind)
jnd = new Date(kink);
liv = valiDate(jnd);
}
            }
//dates get changed based on date pulldowns

function changeSelect(sm,ile){
document.changer.elements[5].checked=true;
var its = sm.form.elements[0].options[sm.form.elements[0].selectedIndex].value + ' ';
var mond = sm.form.elements[1].options[sm.form.elements[1].selectedIndex].text + ' ';
var dey = sm.form.elements[2].options[sm.form.elements[2].selectedIndex].value + ' ';
var blues = mond + ' ' +its+ ', '+dey;
var shin = Date.parse(blues);
var offSetter = '';
if(document.changer.other.value==''){offSetter=document.changer.tink.options[document.changer.tink.selectedIndex].value;}
else{offSetter=document.changer.other.value;}
if(sm.form.name=='ranger'){
var knee = new Date(shin);
var tib = knee.getTime();
var rnu = valiDate(tib);
if(rnu){
JV_dateMaker(knee,0);
document.realForm.elements[0].value=tib;
}
else{
document.realForm.elements[0].value=tib;
}
}
if(sm.form.name=='bob'){
var knee = new Date(shin);
var tib = knee.getTime();
var bnu = valiDate(tib);
if(bnu){
JV_dateMaker(knee,1);
document.realForm.elements[1].value=tib;
}
else{
document.realForm.elements[1].value=tib;
}
}
}
//compare to acceptable date range
function valiDate(pelv){
if(pelv<=choke || pelv>=shank){return false;}
else{
return true;
}
}

function changeIt(selObj, formObj)
{
var tenser = 0;
var selVal = selObj.options[selObj.selectedIndex].value;
val otherVal = formObj.other.value;
init(0,0);
if(formObj.elements[0].checked==true)
{
if(otherVal !=")
   {
      tenser = (val < 0) ? 0 : 1;
    init(Math.abs(otherVal), tenser);
     }
     else
     {
     tenser = (selVal < 0) ? 1 : 0;
     init(Math.abs(selVal), tenser);
     }
    }
    else
    {
alert('Please Check the "Pick Standard Date Range" radio button if you wish to use this feature');
      }
}

function JV_dateMaker(sd,id){
//takes a date in millisecond format and builds a range selector element set
var ly = 0;//decide if it is a leapyear or not
var mll = myLeap.length;
if(document.layers){var yr = sd.getYear()+1900;}
if(document.all){var yr = sd.getYear();}
for(y=0;y<mll;y++){
if(yr == myLeap[y]){ ly = 1;}
}
//decide which option set to populate dates with.
var modaze = "";
      if(sd.getMonth() == 1 && ly == 1){
                                    modaze = 1;
                                    }
      else if(sd.getMonth() == 1 && ly == 0){
                                    modaze = 2;
                                    }
      else if(sd.getMonth() == (3 || 5 || 8 || 10)){
                                    modaze = 3;
                                    }
                              else{
                                    modaze = 0;
                                    }
var vint = myDaze[modaze];
//build out the month options
document.ranger.ma.length = myMonths.length;
document.bob.mb.length = myMonths.length;
for(iggy=0;iggy<myMonths.length;iggy++){
document.ranger.ma.options[iggy].text = myMonths[iggy];
document.ranger.ma.options[iggy].value = iggy;
document.bob.mb.options[iggy].text = myMonths[iggy];
document.bob.mb.options[iggy].value = iggy;
}
//buildout the year options starting with last year
//selecting specified year, and showing 5 more
if(id==0){
for(q=0;q<vint.length;q++){
document.ranger.da.options.length = vint.length;
// build out the date option for the first date selector
document.ranger.da.options[q].text = vint[q];
document.ranger.da.options[q].value = vint[q];
if(q==(sd.getDate() - 1)){
                                          document.ranger.da.selectedIndex = q;
                                          }
                                    }
                  document.ranger.ma.selectedIndex = sd.getMonth();
//set the year options
var rip = startyr;
document.ranger.ya.options.length = showyrs;
for(wink=0;wink<showyrs;wink++){
document.ranger.ya.options[wink].text = wink + rip;
document.ranger.ya.options[wink].value = wink + rip;
}
//set the year
for(laz=0;laz<showyrs;laz++){
if(document.layers){var miyr=(sd.getYear() + 1900);}
if(document.all){var miyr=sd.getYear();}
if(document.ranger.ya.options[laz].value==miyr){
                                          document.ranger.ya.selectedIndex = laz;
                                          }            
}
document.realForm.elements[0].value=sd.getTime();
                              }
if(id==1){
document.bob.db.options.length = vint.length;
// build out the date option for the second date selector
for(q=0;q<vint.length;q++){
document.bob.db.options[q].text = vint[q];
document.bob.db.options[q].value = vint[q];
if(q==(sd.getDate() - 1)){
                                          document.bob.db.selectedIndex = q;
                                          }                                          
                                    }
// set the month
                        document.bob.mb.selectedIndex = sd.getMonth();
//set the year options
var van = startyr;
document.bob.yb.options.length = showyrs;
for(gogh=0;gogh<showyrs;gogh++){
document.bob.yb.options[gogh].text = gogh + van;
document.bob.yb.options[gogh].value = gogh + van;
}
//set the year
for(laz=0;laz<showyrs;laz++){
if(document.layers){var niyr=(sd.getYear() + 1900);}
if(document.all){var niyr=sd.getYear();}
if(document.bob.yb.options[laz].value==niyr){
                                          document.bob.yb.selectedIndex = laz;
                                          }            
}
document.realForm.elements[1].value=sd.getTime();
                              }
}

function init(dif,ichop){
dateCalc(dif,ichop);
if(liv && bee){
liv=false;
bee=false;
JV_dateMaker(ind,0);
JV_dateMaker(jnd,1);
}else{
liv=false;
bee=false;
alert('Out of acceptable parameter range.\nPlease select a shorter\n range or different Date');
}
}

function setupHiddenForm(bx){
//pput in a few values get set for the new window to use
document.changer.elements[5].checked=true;
document.db.whichone.value=bx ;
document.db.forwards.value=shank ;
document.db.backward.value=choke ;
if(document.changer.other.value==""){
var drange = document.changer.tink.options[document.changer.elements[1].selectedIndex].value;
}else{
var drange = document.changer.other.value;
}
document.db.howfar.value=drange;
self.name = 'winop';
showCal('calframe.html','calzone','width=170,height=137');
}

function clearOther(ibis){ibis.form.other.value="";}

function getThisToDate(aDate,wmy){
// Takes a date in miliseconds as the first arguement,
// and wheter it's a week, month or year that you would
// want to calculate. 0=week 1=month 2=year
// returns a start date
var agdate = new Date(aDate);
//because we want to start the week on monday...
var LTweak = new Array(6,0,1,2,3,4,5);
var timebomb=0;
if(wmy==0){
//get the week to date
var minos=agdate.getDay();
var tiker=(agdate.getTime()-(LTweak[minos]*ixday));
var fuse = new Date(tiker);
if(document.layers){
var yeartrap = fuse.getYear() + 1900;
}else{
var yeartrap = fuse.getYear();
}
var C4 = fuse.getDate() + " " + myMonths[fuse.getMonth()] + ", " +  yeartrap
var ignyt=Date.parse(C4);
var timebomb = ((fuse.getTime() - agdate.getTime())/ixday);
}
else if(wmy==1){
//get the month to date
var minos=agdate.getDate();
var tiker=(agdate.getTime()-(minos*ixday));
var fuse = new Date(tiker);
var timebomb=1+((fuse.getTime()- agdate.getTime())/ixday);
}
else if(wmy==2){
//get the year to date
if(document.layers){
//var thisDateIH = "1 January, "+(agdate.getYear()+1900);
var thisDateIH = "1 January, "+(agdate.getYear());
}else{
var thisDateIH = "1 January, "+(agdate.getYear());
}
var minos = Date.parse(thisDateIH);
var fuse = new Date(minos);
fuse.setHours(agdate.getHours());
fuse.setMinutes(agdate.getMinutes());
fuse.setSeconds(agdate.getSeconds());
var wire=((fuse.getTime()- agdate.getTime())/ixday);
var trigger=wire.toString();
var C4 = trigger.split('.');
var timebomb = C4[0];
}
return timebomb;
}

function valiData(rf){
hot = true;
errormsg = 'The Following Errors were found:\n\n';

if(rf.elements[0].value<choke){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected goes back beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[0].value>shank){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected goes forward beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[1].value<choke){
      hot=false
      errormsg= errormsg + 'The End Date you have selected goes back beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[1].value>shank){
      hot=false
      errormsg= errormsg + 'The End Date you have selected goes forward beyond available parameters,\n please adjust your selection\n\n';
      }
if(rf.elements[0].value> rf.elements[1].value){
      hot=false
      errormsg= errormsg + 'The Start Date you have selected is later than your End date,\n please adjust your selection\n\n';
      }




if(hot){
rf.action=frmAction;
rf.submit();
}else{
alert(errormsg);
}
}
// end valiData


function setUpForms(){
//initialize the range list
document.changer.elements[1].options[2].value=getThisToDate(ud.getTime(),0);
document.changer.elements[1].options[3].value=getThisToDate(ud.getTime(),1);
document.changer.elements[1].options[4].value=getThisToDate(ud.getTime(),2);

//document.reportz.graph.options.selectedIndex=oldGraph;
init(0,0);
}//end setUpForms
function setFreq(igna){
document.realForm.elements[2].value=igna.form.elements[0].options[igna.form.elements[0].selectedIndex].value;

}



//-->
    </script>
<!-- END THE JAVASCRIPT BONANZA! -->
<meta name="Microsoft Theme" content="st-pvlogoblue 011, default">
<meta name="Microsoft Border" content="tlb, default">
</head>
<body marginwidth="0" marginheight="0" topMargin="0" leftMargin="0" onload="setUpForms()">
<div align="center">

<!-- BEGIN HEADER TABLE -->
<table class="rptMain" width="100%" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td class="rptHd">&nbsp;Date Range Selector</td>
    <td class="rptHd" align="right"><a href="javascript:self.close();"><img src="img/icon_close.gif" alt="Close" width="15" height="15" border="0"></a></td>
  </tr>
</table>
<!-- END HEADER TABLE -->

<!-- BEGIN INPUT TABLE -->
<table border="0" cellspacing="5" cellpadding="0" width="100%">
  <tr align="center">
    <td align="left" class="blackBld" colspan="4" nowrap>
      &nbsp;</td>
  </tr>
  <tr align="left" valign="top">
    <td class="rptDiv" colspan="4" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
  <tr><form method=post action="" name="changer">
      <!-- BEGIN FIRST PART OF FORM (optional, you can delete this ) -->       

    <td align="left" class="grayBld" nowrap>Date range:</td>
    <td align="left" class="grayBld" nowrap><input type="radio" name="auotrange" value="1" onClick="reset(this.form);init(0,0)" checked></td>
    <td align="left" class="grayBld" colspan="2" nowrap>Pick a standard date range
     
<select name="tink" onChange="changeIt(this, this.form);clearOther(this)">
            <option selected value="0">Today</option>
            <option value="-1">Yesterday</option>
            <option value="-2">Week to Date</option>
            <option value="-13">Month to Date</option>
            <option value="-44">Year to Date</option>
            <option></option>
</select>
      <!-- END FIRST PART OF FORM (optional, you can delete this ) -->       

<input type="hidden" name="direction" value="1">
<!-- forgot what this is for so leave it for now -->
<input type="hidden" name="dunkle" value="0">
<input type="hidden" size="4" maxlength="4" name="other" value="">
    </td>
  </tr>
  <tr align="left" valign="top">
    <td align="left" class="grayBld" nowrap></td>
    <td class="rptDiv" colspan="3" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
      <!-- BEGIN SECOND RADIO BUTTON(optional, you can delete this ) -->       

  <tr>
    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap>
      
      <input type="radio" name="auotrange" value="0"></td>
    <td align="left" class="grayBld" colspan="2" nowrap>Set your own </td></form>
  </tr>
      <!-- END SECOND RADIO BUTTON(optional, you can delete this ) -->       

  <tr><form method=post action="" name="ranger">

    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap></td>
    <td align="right" class="grayBld" nowrap>Start date</td>
    <td align="left" class="grayBld" nowrap>
                  <select name="da" onChange="changeSelect(this,0)";>
                        <option>__</option>
                        <option>__</option>
                        <option>__</option>
                        <option>__</option>
                  </select>
                  <select name="ma" onChange="changeSelect(this,0)">
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>
                        <option>______________</option>

                  </select>
                  <select name="ya" onChange="changeSelect(this,0)">
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                        <option>____</option>
                  </select>
      <a href="#" onClick="setupHiddenForm(1)"><img src="img/btn/use_cal.gif" width="71" height="16" border="0"></a>
    </td></form>
  </tr>
  <tr><form method=post action="" name="bob">
    <td align="left" class="grayBld" nowrap></td>
    <td align="left" class="grayBld" nowrap></td>
    <td align="right" class="grayBld" nowrap>End date</td>
    <td align="left" class="grayBld" nowrap>
            <select name="db" onChange="changeSelect(this,0)">
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
                  <option>__</option>
            </select>
            <select name="mb" onChange="changeSelect(this,0)">
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
                  <option>______________</option>
            </select>
            <select name="yb" onChange="changeSelect(this,0)">
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
                  <option>____</option>
            </select>
      <a href="#" onClick="setupHiddenForm(2)"><img src="img/btn/use_cal.gif" width="71" height="16" border="0"></a>
    </td></form>
  </tr>
  <tr align="left" valign="top">
    <td class="rptDiv" colspan="4" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
 
  </table>
<!-- END INPUT TABLE-->

<!-- BEGIN ACTION BUTTONS TABLE -->
<table border="0" cellspacing="5" cellpadding="0" width="100%">
  <tr align="left" valign="top">
    <td class="rptDiv" nowrap><img src="img/null.gif" width="1" height="1" border="0"></td>
  </tr>
  <tr align="left" valign="top">
    <td nowrap>
<center>     <a href="#" onClick="valiData(document.realForm)"><img src="img/btn/change_paramsOK.gif" width="50" height="16" border="0"></a>
     <a href="#" onClick="self.close()"><img src="img/btn/change_paramsCANCEL.gif" width="50" height="16" border="0"></a></center>
    </td>
  </tr>
</table>
<!-- END ACTION BUTTONS TABLE-->

</div>
<!-- HOLDS THE DATA TO BE USED WITH CALENDARS -->

<form method=post name="db" action="javascript:fromCal()">
<input type="hidden" name="whichone" value="">
<input type="hidden" name="forwards" value="">
<input type="hidden" name="backward" value="">
<input type="hidden" name="doit" value="">
<input type="hidden" name="holdme" value="">
<input type="hidden" name="howfar" value="">
<input type="hidden" name="whereis" value="">
</form>

<!--

HOLDS THE REAL DATA TO BE SUBMITTED FROM THIS FORM
APPEND ANY FEILDS YOU NEED TO ADD TO THIS FORM
      
 -->

<form method=post name="realForm" action="">
<!-- YOU'LL WANT TO MAKE THIS STUFF HIDDEN IN PRODUCTION OF COURSE. -->
<input type="hidden" name="wstartDate" value="" size="20">
<input type="hidden" name="endDate" value="" size="20">
<input type="hidden" NAME="a" VALUE="<%=CSTR(Request.QueryString("ID1"))%>"><br/>

</form>
</body>
</html>

Here is the other file calendarcore.html.
I do not think there is any code in here that effects the year to date problem though.


<HTML>
<head><title>Calendar</title>
<link rel="stylesheet" href="daughter_window.css" type="text/css">
      <style type="text/css">

 <!--
TH {font-size: 10px; font-family: helvetica, verdana, san serif; font-weight: 600; background-color: #EEEEEE}

--></style>
<SCRIPT LANGUAGE="JavaScript">
var tabletop="<table class=\"rptMain\" width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">\n<tr> \n\t\<td class=\"rptHd\">";
var tablebottom="</td>\n\t</tr>\n</table>";
var mover = top.frames[0].document.holder.isit.value;
var ud = new Date();

if(mover==0){
var chud = ud.getTime();
}else{
dateHelper = new Date(top.frames[0].document.holder.nextMonth.value);
chud = dateHelper.getTime();
}
var sbd = (chud - (0*24*60*60*1000));
if (parent.window.opener){
var choke = parent.window.opener.document.db.backward.value;
var shank = parent.window.opener.document.db.forwards.value;
var wig = parent.window.opener.document.db.whichone.value;
var getReal = new Date();


}else{
var deadhistory = '6 February, 2000';
var deadfuture = '27 February, 2000';
var choke = Date.parse(deadhistory);
var shank = Date.parse(deadfuture);
var getReal = new Date();

//var getReal = new Date();


}

function achiveData(olddate,dir){

var fud = Date.parse(olddate);

var newFromOld = new Date(fud);
var mid = newFromOld.getMonth();
if ((mid + dir) == -1){
mid = 13;
}else if((mid+dir)==12){
mid = 0;
}else{
mid++;
}

if(document.layers){
var yid = newFromOld.getYear() + 1900;
}else{
var yid = newFromOld.getYear();
}
if(mid==13 || mid==0){
yid = yid + dir;
}

var zaa = "1 " + Months[(mid + dir)] + ", " + yid;

top.frames[0].document.holder.nextMonth.value=zaa;
this.window.location.reload(true);

}

function sendBack(btz){

parent.window.opener.document.db.doit.value = 1;
parent.window.opener.document.db.whichone.value = wig;
parent.window.opener.document.db.holdme.value = new Date(btz);
parent.window.opener.document.db.submit();
parent.window.opener.focus();
parent.window.close();
}
function doTheMath(jvr,tew){
//day
var ik = tew;
//month
var ee = Months[jvr.getMonth()+1] + ' ';

//year
if(document.layers){
var fixNS = jvr.getYear() + 1900;
var poo = fixNS + ' ';
}else{
var poo = jvr.getYear() + ' ';

}

var puk = ik + ' ' +ee+ ', '+poo;
var poru = Date.parse(puk);

return poru;

}
function montharray(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)

{

   this[0] = m0;

   this[1] = m1;

   this[2] = m2;

   this[3] = m3;

   this[4] = m4;

   this[5] = m5;

   this[6] = m6;

   this[7] = m7;

   this[8] = m8;

   this[9] = m9;

   this[10] = m10;

   this[11] = m11;

}



function MakeArray(n) {this.length = n; return this;}

  var Days = new MakeArray(7);

  var Months = new MakeArray(12);

  Days[1]="Sunday"; Days[2]="Monday"; Days[3]="Tuesday";   Days[4]="Wednesday";

  Days[5]="Thursday"; Days[6]="Friday"; Days[7]="Saturday";

  Months[1]="January"; Months[2]="February"; Months[3]="March";   Months[4]="April";

  Months[5]="May"; Months[6]="June"; Months[7]="July";   Months[8]="August";

  Months[9]="September"; Months[10]="October"; Months[11]="November";

  Months[12]="December";



  function getNiceDate(theDate) {

  return Days[theDate.getDay()+1] + " " + theDate.getDate() + " " +

  Months[theDate.getMonth()+1] + " " + theDate.getYear(); }



function calendar()

{

// identify window
if(wig==1){
document.write(tabletop + 'Select Start Date' + tablebottom );
}
if(wig==2){
document.write(tabletop + 'Select End Date'  + tablebottom );
}  

      today = new Date(sbd);

   var thisDay;

   var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";

   var monthNames2 = " 1 2 3 4 5 6 7 8 9 10 11 12";

   var monthDays = new montharray(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if(document.layers){
   year = today.getYear() + 1900;
}else{
   year = today.getYear();

}
   thisDay = today.getDate();


   if (year == (2000 || 2004 || 2008 || 2012 || 2016 || 2020 || 2024 || 2028 || 2032 || 2036 || 2040))

      monthDays[1] = 29;
   nDays = monthDays[today.getMonth()];

   firstDay = today;

   firstDay.setDate(1);

   var lastMod = new Date(sbd);

   startDay = firstDay.getDay();
   document.write("<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"170\" align=\"center\">\n");

   document.write("<tr>\n\t<th align=\"left\"><a href=\"#\" onClick=\"achiveData(\'");
   document.write(today);
   document.write("\', -1)\"><img src='img/btn/arw_lft.gif' vspace='1' hspace='2' width='11' height='11' border=0 alt='bk'></a></th>\n\t<th colspan=5>");

   document.write(Months[today.getMonth()+1]+", "+year);

   document.write("</th>\n\t<th align=\"right\"><a href=\"#\" onClick=\"achiveData(\'");
   
   document.write(today);
   document.write("\', 1)\"><img src='img/btn/arw_rt.gif' vspace='1' hspace='2' width='11' height='11' border=0 alt='bk'></a></th>\n</tr>\n");
      document.write("<tr>\n\t<td class='dazJV'>Su</td>\n\t<td class='dazJV'>M</td>\n\t<td class='dazJV'>Tu</td>\n\t<td class='dazJV'>W</td>\n\t<td class='dazJV'>Th</td>\n\t<td class='dazJV'>F</td>\n\t<td class='dazJV'>Sa</td>\n</tr>\n");
   document.write("<tr>\n");

   column = 0;

   for (i=0; i<startDay; i++){

      document.write("\t<td align='center' class='nodyJV'>");
      document.write("&nbsp;</td>\n");
      column++;
   }

   for (i=1; i<=nDays; i++) {

//alert(i + "-" + today.getMonth() + "  --  " + getReal.getDate() + "-" + getReal.getMonth());

      if (column == 0) {

         document.write("<tr>\n<td class='wkndJV' align='center'>");
}
     else if (column == 6) {

         document.write("\t<td class='wkndJV' align='center'>");              
}
    else if ((getReal.getMonth()==today.getMonth()) && (i==getReal.getDate())){document.write("<td class='2dyJV' align='center' bgcolor='#000000'>");
//alert(getReal.getMonth() + " - " + today.getMonth());
      }

        else{
              document.write("\t<td class='wkdyJV' align='center'>");

        }
        
        //need to get the this date, parse it back to ms and compare it to our dead days
var dtp=doTheMath(lastMod,i);
if(dtp>choke && dtp<shank){

if((getReal.getMonth()==today.getMonth()) && (i==getReal.getDate())){

      document.write("<a href='#' class='calJV' onClick='sendBack(" + dtp + ")' >");
      document.write(i);
      document.write("</a></td>\n");
}

else{
      document.write("<a href='#' onClick='sendBack(" + dtp + ")' >");
      document.write(i);
      document.write("</a></td>\n");
      }
}else{
document.write(i + "</td>\n");
}
column++;

      if (column == 7){

         document.write("</tr>\n");

         column = 0;

      }

   }
if(column==0){
   document.write("</table>");
   }else{
   document.write("<td colspan='" + Math.abs(column-7) + "' class='nodyJV'>&nbsp;</td></table>");
}
top.frames[0].document.holder.isit.value=1;

}

</SCRIPT>
</head>
<BODY  marginwidth="0" marginheight="0" topMargin="0" leftMargin="0">

<CENTER>


<SCRIPT LANGUAGE="JavaScript">

<!--
calendar();
 //-->
</SCRIPT>

</CENTER>

</BODY>

</HTML>
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9630625
did you type it in or cut&paste
because 2 typos so far:

 val otherVal = formObj.other.value;
should be:
 var otherVal.....

this:
    if(otherVal != '')

is "" or '' -- quotes with empty space

Vinny
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9630639
now I'm getting 'frames' errors in ie --which does come up jan1 but in nn6.1 I get out of range errors.  Did you change stuff?

Vinny
0
 

Author Comment

by:TrueBlue
ID: 9630765
Hi Vinny!

I did hand type the changes in because when I cut and pasted them. They were all messed up.
I did make a few typos, but I did not change anything other than your suggestions. I am still getting errors though.

Here is your code from calendar.html now:

function changeIt(selObj, formObj)
{
var tenser = 0;
var selVal = selObj.options[selObj.selectedIndex].value;
var otherVal = formObj.other.value;
init(0,0);
if(formObj.elements[0].checked==true)
{
if(otherVal != ")
   {
      tenser = (val < 0)? 0:1;
    init(Math.abs(otherVal), tenser);
     }
     else
     {
     tenser = (selVal < 0)? 1:0;
     init(Math.abs(selVal), tenser);
     }
    }
    else
    {
alert('Please Check the "Pick Standard Date Range" radio button if you wish to use this feature');
      }
}
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9636261
Hi Chuck,

   It works for me --
the 'out of range errors are coming from the 'opener' and frame code -- so, you either have to provide a url or figure it out yourself.

Again, this thing is a mess.

Vinny
0
 

Author Comment

by:TrueBlue
ID: 9638626
Hi Vinny!

Thank you for help.

This form outputs the start and end date in milliseconds.

Do you know how I could convert milliseconds to a date that could be used in a SQL Select statement?

Chuck
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9638668
var milliseconds = 937858019615;
var myDate = new Date(milliseconds);
alert(myDate)

Vinny
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9638676
I'm not sure what sql server requires -- you should check the manual
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now