Solved

make this work twice

Posted on 2006-10-31
3
338 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Example unit tests with AngularJS 3 40
Javascript and Jquery not firing 9 37
Message not shown 5 29
jQuery Validate 4 11
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…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

919 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

18 Experts available now in Live!

Get 1:1 Help Now