473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening calendar in new window

79 New Member
The code below is opening a calendar on mouse over in the same window.
I need the calendar to be opened in new window.
Have to fulfill this requirement urgentely so posting the whole code here.
I tried doing some workaround using
Expand|Select|Wrap|Line Numbers
  1. window.open()
but not getting the calendar in new window.
[html]

<html>

<head>
<script language="JavaS cript">

<!--
var months = new Array("January" , "February", "March", "April", "May", "June", "July", "August", "September" , "October", "November", "December") ;
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var days = new Array("S", "M", "T", "W", "T", "F", "S");

today = new getToday();
var element_id;

function getDays(month, year)
{
// Test for leap year when February is selected.
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}

function getToday()
{
// Generate today's date.
this.now = new Date();
this.year = this.now.getFul lYear() ; // Returned year XXXX
this.month = this.now.getMon th();
this.day = this.now.getDat e();
}


function newCalendar()
{
var parseYear = parseInt(docume nt.all.year [document.all.ye ar.selectedInde x].text);

var newCal = new Date(parseYear , document.all.mo nth.selectedInd ex, 1);
var day = -1;
var startDay = newCal.getDay() ;
var daily = 0;

today = new getToday(); // 1st call
if ((today.year == newCal.getFullY ear() ) && (today.month == newCal.getMonth ()))
day = today.day;
// Cache the calendar table's tBody section, dayList.
var tableCal = document.all.ca lendar.tBodies. dayList;

var intDaysInMonth =
getDays(newCal. getMonth(), newCal.getFullY ear() );

for (var intWeek = 0; intWeek < tableCal.rows.l ength; intWeek++)
for (var intDay = 0;
intDay < tableCal.rows[intWeek].cells.length;
intDay++)
{
var cell = tableCal.rows[intWeek].cells[intDay];

// Start counting days.
if ((intDay == startDay) && (0 == daily))
daily = 1;

// Highlight the current day.
cell.style.colo r = (day == daily) ? "red" : "";
if(day == daily)
{
document.all.to dayday.innerTex t= "Today: " + day + "/" +
(newCal.getMont h()+1) + "/" + newCal.getFullY ear() ;
}
// Output the day number into the cell.
if ((daily > 0) && (daily <= intDaysInMonth) )
cell.innerText = daily++;
else
cell.innerText = "";
}

}

function getTodayDay()
{
document.all[element_id].value = today.day + "/" + (today.month+1) +
"/" + today.year;
//document.all.ca lendar.style.vi sibility="hidde n";
document.all.ca lendar.style.di splay="none";
document.all.ye ar.selectedInde x =100;
document.all.mo nth.selectedInd ex = today.month;
}

function getDate()
{
// This code executes when the user clicks on a day
// in the calendar.
if ("TD" == event.srcElemen t.tagName)
// Test whether day is valid.
if ("" != event.srcElemen t.innerText)
{
var mn = document.all.mo nth.selectedInd ex+1;
var Year = document.all.ye ar [document.all.ye ar.selectedInde x].text;
// document.all[element_id].value=event.sr cElement.innerT ext+"/"+mn +"/" +Year;
document.all[element_id].value=mn+"/"+ event.srcElemen t.innerText+"/" +Year;
//document.all.ca lendar.style.vi sibility="hidde n";
document.all.ca lendar.style.di splay="none";
}
}

function PassDate()
{
// This code executes when the user clicks on a day
// in the calendar.
if ("TD" == event.srcElemen t.tagName)
// Test whether day is valid.
if ("" != event.srcElemen t.innerText)
{
var mn = document.all.mo nth.selectedInd ex+1;
var Year = document.all.ye ar [document.all.ye ar.selectedInde x].text;
// document.all[element_id].value=event.sr cElement.innerT ext+"/"+mn +"/" +Year;
var datePass=mn+"/"+ event.srcElemen t.innerText+"/" +Year;
document.all[element_id].value=mn+"/"+ event.srcElemen t.innerText+"/" +Year
strURL="../redirect.jsp"
strURL+="?date= " + datePass;
parent.frames['MAINBODY1'].location.href= strURL
}
}

function GetBodyOffsetX( el_name, shift)
{
var x;
var y;
x = -30;
y = 0;

var elem = document.all[el_name];
do
{
x += elem.offsetLeft ;
y += elem.offsetTop;
if (elem.tagName == "BODY")
break;
elem = elem.offsetPare nt;
} while (1 > 0);

shift[0] = x;
shift[1] = y;
return x;
}

function SetCalendarOnEl ement(el_name)
{
if (el_name=="")
el_name = element_id;
var shift = new Array(2);
GetBodyOffsetX( el_name, shift);
document.all.ca lendar.style.pi xelLeft = shift[0]; // - document.all.ca lendar.offsetLe ft;
document.all.ca lendar.style.pi xelTop = shift[1] + 45 ;
}



function ShowCalendar(el em_name)
{
if (elem_name=="")
elem_name = element_id;

element_id = elem_name; // element_id is global variable
newCalendar();
SetCalendarOnEl ement(element_i d);
//document.all.ca lendar.style.vi sibility = "visible";
document.all.ca lendar.style.di splay="inline";
}

function HideCalendar()
{
//document.all.ca lendar.style.vi sibility="hidde n";
document.all.ca lendar.style.di splay="none";
}

function toggleCalendar( elem_name)
{
//if (document.all.c alendar.style.v isibility == "hidden")
if(document.all .calendar.style .display=="none ")
ShowCalendar(el em_name);
else
HideCalendar();
}

function fillDate()
{
d = new Date();
curr_year = d.getFullYear() ;
curr_month = d.getMonth();
curr_day = d.getDate();
curr_date=curr_ month+"/"+curr_day+ "/"+curr_year ;
document.getEle mentById('MyDat e').value=curr_ date;

}

function opencal()
{
window.open ("cal.jsp","myw indow","status= 1,width=100,hei ght=100");
}
-->
</script>

<style>

.today {COLOR: black; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold}
.days {COLOR: navy; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold; TEXT-ALIGN: center}
.dates {COLOR: black; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt}
</style>
<LINK href="../stylesheet/content.css" type=text/css rel=stylesheet>
<LINK href="../stylesheet/master.css" type=text/css rel=stylesheet>
<LINK href="../stylesheet/vsadmin.css" type=text/css rel=stylesheet>
</head>

<body onload="fillDat e()" bgcolor=#FFFFDF >
<FORM name=myForm>
<INPUT id=MyDate name=MyDate size=15>
<a href="JavaScrip t:;" onmouseover="to ggleCalendar('M yDate')">Calend ar</a>
<!--<a href="JavaScrip t:;" onmouseover="op encal();">Calen dar</a>-->
</form>
<TABLE bgColor=#ffffff border=1 cellPadding=0 cellSpacing=3 id=calendar style="DISPLAY: none; POSITION: absolute; Z-INDEX: 4; left:0px; top:19px; width:78px; height:50px">
<TBODY>
<TR>
<TD colSpan=7 vAlign=center >
<!-- Month combo box -->
<SELECT id=month onchange=newCal endar()>
<SCRIPT language=JavaSc ript>
// Output months into the document.
// Select current month.
for (var intLoop = 0; intLoop < months.length; intLoop++)
document.write( "<OPTION " + (today.month == intLoop ? "Selected" : "") + ">" + months[intLoop]);
</SCRIPT>
</SELECT>
<!-- Year combo box -->
<SELECT id=year onchange=newCal endar()>
<SCRIPT language=JavaSc ript>
// Output years into the document.
// Select current year.
for (var intLoop = 1900; intLoop < 2028; intLoop++)
document.write( "<OPTION " + (today.year == intLoop ? "Selected" : "") + ">" + intLoop);
</SCRIPT>
</SELECT>

</TD>
</TR>



<TR class=days>
<!-- Generate column for each day. -->
<SCRIPT language=JavaSc ript>
// Output days.
for (var intLoop = 0; intLoop < days.length; intLoop++)
document.write( "<TD>" + days[intLoop] + "</TD>");
</SCRIPT>
</TR>


<!-- <TBODY class=dates id=dayList onclick="getDat e('')" vAlign=center>-->
<TBODY class=dates id=dayList onclick="PassDa te('')" vAlign=center>
<!-- Generate grid for individual days. -->
<SCRIPT language=JavaSc ript>
for (var intWeeks = 0; intWeeks < 6; intWeeks++)
{
document.write( "<TR>");
for (var intDays = 0; intDays < days.length; intDays++)
document.write( "<TD></TD>");
document.write( "</TR>");
}
</SCRIPT>

<!-- Generate today day. --></TBODY>
<TBODY>
<TR>
<TD class=today colSpan=5 id=todayday onclick=getToda yDay()></TD>
<TD align=right colSpan=2><A href="javascrip t:HideCalendar( );"><SPAN style="COLOR: black; FONT-SIZE: 10px"><B>Hide</B></SPAN></A></TD>
</TR>
</TBODY>

</TABLE>





</body>

</html>
[/html]
Mar 25 '08 #1
1 3710
acoder
16,027 Recognized Expert Moderator MVP
Your code just shows the calendar within the page. Move all the code to the new window page.
Mar 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2527
by: vinu | last post by:
I have a javascript file named select.js. This is a file which is use to pop up a calendar, when clicked on a calendar icon in an ASP file. have a close button in the calendar. When i click on the button, th calendar is not closing. here is the select.js file x999NS4compatible = (document.layers); var x999IE4compatible = (document.all); var x999dayabbs = ;
16
3060
by: DFS | last post by:
If you're listening, I want the middle of the calendar (showing 1 month) to open below the cursor position. It currently opens just to the right and below the cursor position. I hunted through the code, but can't determine what to alter. Very nice piece of work, by the way. Thanks
6
1651
by: Jeff S | last post by:
I would like recommendations for implementing a calendar in an ASP.NET web site. My plan is to store date and event information (e.g,, "Spring Sale") in a database, and when the page is requested, load the calendar. Users would ideally view an entire month, and a short description of an event within a specific date. More than one event will be listed for some dates, with a brief description displayed in the calendar. I'd like to enable...
0
1746
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
2
3417
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
0
3327
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
13
2263
by: NoaD | last post by:
Hello i have a button that clicking on it should open a pop-up with a calendar. I'm working with IE 7. the behaviour that follows clicking on the button is not persistent. if i use the mouse to click the button i succeed, but when i navigate with tabs, sometimes it works right away, sometimes it needs 1-2 tries to open the window, and sometimes it doesn't succeed. the problem is that window.open(...) returns null
4
3356
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.