Solved

make this work twice

Posted on 2006-10-31
3
339 Views
Last Modified: 2010-08-05
Hi

How would it be possible please for me to get two instances of this working on one page

to see what it does go here
http://teamconsole.eu/test.php

code is here
<script src="CalendarPopup.js"></script>
<div align="center">
<SCRIPT LANGUAGE="JavaScript" ID="js10">

var cal = new CalendarPopup();

function Yesterday()
    {
      y = new Date();
      y.setHours( 12 );
      y.setTime( y.getTime() - 86400000 );
      return y;
    }
now =  Yesterday();
cal.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
cal.setReturnFunction("setMultipleValues2");
function setMultipleValues2(y,m,d) {
      
      document.forms['example'].date_year.value=y;
      document.forms['example'].date_month.value=LZ(m);
      document.forms['example'].date_day.value=LZ(d);
      }
</SCRIPT>

   <table border="0" align="center" cellpadding="4" cellspacing="0">
                  <form name="example" method="post" action="guestlists.php">
                    <tr>
                      <td height="52" align="center" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><A HREF="#" onClick="cal.showCalendar('anchor1'); return false;" TITLE="cal.showCalendar('anchor1'); return false;" NAME="anchor1" ID="anchor1">select date<br>
                      </A></td>
                      <td><INPUT NAME="date_month" value="<?=$date_month?>" TYPE="text" SIZE=3 maxlength="2">
                        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">/</font>
                        <INPUT NAME="date_day" value="<?=$date_day?>" TYPE="text" SIZE=3 maxlength="2">
                        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">/</font>
                        <INPUT NAME="date_year" TYPE="text" value="<?=$date_year?>" SIZE=5 maxlength="4"><br>
                        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Date [mm/dd/yyyy]</font></td>
                    </tr>
                 
              </table>  
0
Comment
Question by:avo42
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 500 total points
ID: 17845709
Create a cal2 instance of the calendar.

<SCRIPT LANGUAGE="JavaScript" ID="js10">

var cal = new CalendarPopup();
var cal2 = new CalendarPopup();

function Yesterday()
    {
      y = new Date();
      y.setHours( 12 );
      y.setTime( y.getTime() - 86400000 );
      return y;
    }
now =  Yesterday();
cal.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
cal.setReturnFunction("setMultipleValues2");
cal2.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
cal2.setReturnFunction("setMultipleValues2_new");
function setMultipleValues2(y,m,d) {
     
     document.forms['example'].date_year.value=y;
     document.forms['example'].date_month.value=LZ(m);
     document.forms['example'].date_day.value=LZ(d);
     }
function setMultipleValues2_new(y,m,d) {
     document.forms['example2'].date_year.value=y;
// or you could have the input boxes in the same form like document.forms['example'].date_year2.value=y;
     document.forms['example2'].date_month.value=LZ(m);
     document.forms['example2'].date_day.value=LZ(d);
     }
</SCRIPT>


0
 

Author Comment

by:avo42
ID: 17846005
Hi Thank you

works great appriciated

Do you know of a clock that will do the same as this but output time


thanks again.
0
 
LVL 15

Expert Comment

by:danrosenthal
ID: 17846271
Not off hand.
This site has tons of little scripts: http://javascript.internet.com/
Other than that, I would just do a Google search for one.
Good Luck!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

777 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