Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Calendars on One Page

Status
Not open for further replies.

mak2112

IS-IT--Management
Aug 8, 2001
46
I want to have multiple calendars running on a page, I can get one to work, however when i duplicate the coding and change the names to the fields i want populated it does not work, any ideas as to why?

<head>
<title></title>
<SCRIPT LANGAUGE=&quot;JavaScript&quot;>
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var month = today.getMonth();
var day = today.getDate();
var year = y2k(today.getYear());

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart() {
document.create.fielda.value = ''+ padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
mywindow.close();
}

function newWindow() {
mywindow = window.open('calendar.htm','myname','resizable=no,width=350,height=270');
mywindow.location.href = 'calendar.htm';
if (mywindow.opener == null) mywindow.opener = self;

}
</SCRIPT>

<SCRIPT LANGAUGE=&quot;JavaScript&quot;>
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var month = today.getMonth();
var day = today.getDate();
var year = y2k(today.getYear());

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart() {
document.create.fieldb.value = ''+ padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
mywindow.close();
}

function newWindow() {
mywindow = window.open('calendar.htm','myname','resizable=no,width=350,height=270');
mywindow.location.href = 'calendar.htm';
if (mywindow.opener == null) mywindow.opener = self;

}
</SCRIPT>
 
If you have the script sections just as you have them here, then it may be because you have duplicate functions, y2k, restart, newWindow, padout. You only need to define them once. I'd pass the field you want populated to the restart function instead of hardcoding it, then you only need to have one instance.

Code:
function restart(field) {
    fld = eval(&quot;document.create.&quot; + field);
    fld.value = ''+ padout(month - 0 + 1) + '/'  + padout(day) + '/' + year;
    mywindow.close();         
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top