hi all,
iam new to javascript. i have problem calling javascript functions.iam designing a calender page.here is my code.
[HTML]<%@ page import='java.io .*,java.util.*, java.sql.*,java x.servlet.*,jav ax.servlet.http .*' session='true'% >
<%@ page import='java.te xt.*'%>
<html>
<script language='javas cript'>
function backward()
{
alert("hello");
}
function forward()
{
alert("in forward");
}
function display()
{
var months=new Array("Jan","Fe b","Mar","Apr", "May","Jun","Ju l","Aug","Sep", "Oct","Nov","De c");
var weekdays=new Array("Sun","Mo n","Tue","Wed", "Thur","Fri","S at");
var givenmonth=docu ment.frm.month. value;//alert(givenmont h);
var givendate=docum ent.frm.date.va lue;//alert(givendate );
var datelimit;
var today=new Date();//alert(today);
var temp=new String(today);//alert(temp);
var todayday=temp.s ubstring(0,3);//alert(todayday) ;
var todaymonth=temp .substring(4,7) ;//alert(todaymont h);
var todaydate=temp. substring(8,10) ;alert(todaydat e);
var start=todaydate-7;//alert("start="+ start);
var firstday,firstb rk,secondbrk,th irdbrk,fourthbr k;
if(start<7)
{
firstday=weekda ys[start-1];
//alert("firstday "+firstday) ;
}
firstbrk=8-start;secondbrk =firstbrk+7;thi rdbrk=secondbrk +7;fourthbrk=th irdbrk+7;
if(givenmonth== 'Jan' ||givenmonth==' Mar' ||givenmonth==' May' || givenmonth=='Ju l' || givenmonth=='Au g' || givenmonth=='Oc t' || givenmonth=='De c')
{
datelimit=31;//alert(datelimit );
}
if(givenmonth== 'Apr' ||givenmonth==' Jun' ||givenmonth==' Sep' || givenmonth=='No v')
{
datelimit=30;//alert(datelimit );
}
if(givenmonth== 'Feb')
{
datelimit=28;//alert(datelimit );
}
document.write( "<table border=1>"+"<tr >"+"<td colspan=2>");
document.write( "<input type=button name=button value=Back onclick=>"+"</td>");
document.write( "<td colspan=3>"+"<i nput type=text name=month value=Nov>"+"</td>");
document.write( "<td colspan=2>"+"<i mg src=e_forward.g if onclick=forward ()>"+"</td>"+"</tr>");
document.write( "<tr>");
for(var a=0;a<weekdays. length;a++)
{
document.write( "<td>"+week days[a]+"</td>");
}
document.write( "</tr><tr>");
for(var a=1;a<start;a++ )
{
document.write( "<td></td>");
}
for(var a=1;a<datelimit ;a++)
{
document.write( "<td>");
if(todaydate==a )
{
document.write( "<font color=red>");
}
if(givendate==a && todaymonth==giv enmonth)
{
document.write( "<font color=blue>");
}
document.write( a);
if(a==firstbrk || a==secondbrk || a==thirdbrk || a==fourthbrk)
document.write( "</td></tr>");
}
document.write( "</table>");
}
</script>
<body bgcolor='#fofof o'>
<form name='frm'>
<%!
String entereddate,ent eredyear,entere dmonth,enteredd ay;
%>
<%
entereddate=req uest.getParamet er("entereddate ");
out.println("en tereddate"+ente reddate);
StringTokenizer stz1=new StringTokenizer (entereddate,"-");
enteredyear=stz 1.nextToken();o ut.println("ent eredyear="+ente redyear);
if(stz1.hasMore Tokens()){
enteredmonth=st z1.nextToken(); out.println("en teredmonth="+en teredmonth);
enteredday=stz1 .nextToken();ou t.println("ente redday="+entere dday);
}
%>
<BR>
Month:<input type='text' name='month' value='<%=enter edmonth%>'>
<BR>
Date:<input type='text' name='date' value='<%=enter edday%>'>
<BR>
<input type='button' name='button' value='display' onclick='displa y()'>
</form>
</body>
</html>[/HTML]
the backward and forward functions ar giving errors pls help
1 7534 acoder 16,027
Recognized Expert Moderator MVP
Welcome to TSDN!
You can't use document.write after the page has loaded.
Create the table and append to the body/a div using appendChild, or you could even use innerHTML, or have the calendar ready and just display when needed.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mario Thiel |
last post by:
Hello,
i am new to JavaScript and right now i am learning Call by Value. i
tryed to write a small script but somehow it doesnt work right. i cant
put <br> into it, and i can only put the document.write(xyz,x) in the
function.
<html>
<head>
<script language="JavaScript">
|
by: Sue |
last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided
to improve character checking on my project. In my project I only had
to do very basic validation. Therefore, I only had one function to
verify the name fields, age, email and gender.
My question is: if I create a function for each field like the code
below, what would be the best way to organize the functions and call
them? Would I need one main function and place...
|
by: JesusFreak |
last post by:
From: us_traveller@yahoo.com (JesusFreak)
Newsgroups: microsoft.public.scripting.jscript
Subject: toolbar script problem
NNTP-Posting-Host: 192.92.126.136
Recently, I downloaded the following beautiful script
"http://javascript.internet.com/navigation/toolbar-menu.html". It
works like a charm. I made my webpage in frames, where the nav-frame
shows the menubar, so whenever I click a link in the menubar, it opens
in the frame below. But...
|
by: dmiller23462 |
last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript
but my end result is I need two text boxes to stay hidden until a
particular option is selected....I've cobbled together the JavaScript
in this code from a couple different sites but I'm not 100% sure what
each line is doing...This is the ASP code that I'm using for the
page....Take a look at the JavaScript code and please let me know what
each line is doing....I have been...
|
by: tshad |
last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an
asp.net problem or a javascript problem.
I have a page that was originally created from a program I found on the net
that works well as an html page.
It brings up a modal popup window that I have been trying to work out for
days now and this was the closest I have been able to come.
I added a little asp.net code and an asp.net button and cannot get it to
| |
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. When it completes, it can call a success, or a failure
function. The names of these success, or failure functions will differ,
and I'd like to know how I can pass the name of a function to my tool,
and how my tool can call the function, using that...
|
by: tshad |
last post by:
This is from my previous post, but a different issue.
I have the following Javascript routine that opens a popup page, but doesn't
seem to work if called from an asp.net button. It seems to work fine from a
link.
The button does bring up the popup window, but when I press the links on the
page, it doesn't return or close the window.
****************************************************************************
|
by: chrisdude911 |
last post by:
how do i add video into a javascript web page with my own custom
buttons?
|
by: tim |
last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus
in firefox. On my sub3 menus i have more than one line of text in some
places. firefox does not recognise that there is more than one line
and the text simply overlaps the sub-menus below it. I thought i had
got around this by placing empty 'spacers' like so;
oFoldMenu.make('sub3','')//spacer
unfortunately, i have just viewed the site in IExplorer and it has
added...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |