473,888 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two drop-down list that used the same javascript function.

2 New Member
Good morning all,

Please I need help in a form that I have designed to fill user information. This form needs two drop-down list about specific date, one about contract date, and the other about birth date. I am using java script function to display the dates, and use onload() function to set the drop-down list to the current date.

I following error used to appear (null or not an object)!! Can any one help me in that?

The code:



//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(Whi chMonth, WhichYear)
var DaysInMonth = 31;
if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(Whic hYear/4)) DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(Whic hYear/4)) DaysInMonth = 29;
return DaysInMonth;

//function to change the available days in a months
function ChangeOptionDay s(Which)
DaysObject = eval("document. Englishform." + Which + "Day");
MonthObject = eval("document. Englishform." + Which + "Month");
YearObject = eval("document. Englishform." + Which + "Year");

Month = MonthObject[MonthObject.sel ectedIndex].text;
Year = YearObject[YearObject.sele ctedIndex].text;

DaysForThisSele ction = DaysInMonth(Mon th, Year);
CurrentDaysInSe lection = DaysObject.leng th;
if (CurrentDaysInS election > DaysForThisSele ction)
for (i=0; i<(CurrentDaysI nSelection-DaysForThisSele ction); i++)
DaysObject.opti ons[DaysObject.opti ons.length - 1] = null
if (DaysForThisSel ection > CurrentDaysInSe lection)
for (i=0; i<(DaysForThisS election-CurrentDaysInSe lection); i++)
NewOption = new Option(DaysObje ct.options.leng th + 1);
DaysObject.add( NewOption);
if (DaysObject.sel ectedIndex < 0) DaysObject.sele ctedIndex == 0;

//function to set options to today
function SetToToday(Whic h)
DaysObject = eval("document. Englishform." + Which + "Day");
MonthObject = eval("document. Englishform." + Which + "Month");
YearObject = eval("document. Englishform." + Which + "Year");

YearObject[0].selected = true;
MonthObject[NowMonth].selected = true;

ChangeOptionDay s(Which);

DaysObject[NowDay-1].selected = true;

//function to write option years minus x
function WriteYearOption s(YearsAhead)
line = "";
for (i=0; i<YearsAhead; i++)
line += "<OPTION>";
line += NowYear--;
return line;
// End -->

<body onLoad="SetToTo day('FirstSelec t');" >
<FORM NAME="Englishfo rm" >
<!-- Contract date -->
<LABEL>Contra ct date</LABEL>
<SELECT name="FirstSele ctMonth" onchange="Chang eOptionDays('Fi rstSelect')"><O PTION>Jan <OPTION>Feb <OPTION>Mar<OPT ION>Apr <OPTION>May <OPTION>Jun <OPTION>Jul <OPTION>Aug <OPTION>Sep <OPTION>Oct <OPTION>Nov <OPTION>Dec</SELECT>
<SELECT name="FirstSele ctYear" onchange="Chang eOptionDays('Fi rstSelect')"> <SCRIPT language="JavaS cript">
document.write( WriteYearOption s(10)); </SCRIPT></SELECT>

<!-- Date of birth -->
<LABEL>Date of issue</LABEL>
<SELECT name="FirstSele ctDay2"> <OPTION>1 <OPTION>2 <OPTION>3 <OPTION>4 <OPTION>5 <OPTION>6 <OPTION>7
<SELECT name="FirstSele ctMonth2" onchange="Chang eOptionDays('Fi rstSelect')"> <OPTION>Jan <OPTION>Feb <OPTION>Mar
<SELECT name="FirstSele ctYear2" onchange="Chang eOptionDays('Fi rstSelect')"> <SCRIPT language="JavaS cript">
document.write( WriteYearOption s(50)); </SCRIPT></SELECT>
<INPUT type=submit value=Submit name=Submit></DIV><br>
Jan 28 '08 #1
3 1902
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

What line does the error occur on?
Jan 28 '08 #2
2 New Member
Thanks for replying !

Line 100. Plz help me through :(
Jan 28 '08 #3
16,027 Recognized Expert Moderator MVP
The add() method of the select object has two arguments in standard-compliant browsers (i.e. browsers other than IE). See, for example, this link.
Jan 28 '08 #4

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

Similar topics

by: Ryan | last post by:
Just a quicky about temporarary tables. If using QA, when you create a temporary table, it gets dropped if you close the query. Otherwise you need to state 'DROP TABLE myTable' so that you can re-run the query without the table being there. Sometimes, you can have quite lengthy SQL statements (in a series) with various drop table sections throughout the query. Ideally you would put these all at the end, but sometimes you will need to...
by: hemant_mishal | last post by:
Hi All, I am writting a java script library which will provide inter frame drag and drop operation. The more precise will be OLE drag and drop, which means only data will be transfered from frame to frame not any object. But it should happen in a drag and drop fashion. The requirement is, user will click on one object and will drag the mouse to another frame and will drop on some object the data will be passed by this and some action will...
by: Ian Dobson | last post by:
Hi, I need to drop a schema from a database but it has 400 tables in it. Is there an easy way to do it other than drop table schema1.table1 drop table schema1.table2 etc.. to 400 and then drop schema schema1? thanks
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not null references another, FK_LASTLYOID bigint not null references lastly, unique (FK_OTHEROID,FK_ANOTHEROID))
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
by: Markus | last post by:
I tried this: ALTER TABLE Dokumente DROP COLUMN docPrioID but I get this errormessage: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: COLUMN;ABLE Dokumente DROP;CONSTRAINT
by: Darren | last post by:
I'm trying to create a file using drag and drop. I want to be able to select a listview item drag it to the shell and create a file. Each icon in the listview represents a blob in a database. When I drop onto the shell I want a file created with a specified name containing the data from the database. I've looked at the FileDrop format but it look to have only the filename and not the data. TIA
by: joey.powell | last post by:
I have a Windows Forms application where I need to be able to drag and then drop onto a datagridview control. I already have the code necessary to make the drag part work. I am having problems, however, when I attempt to drop onto a cell in the datagridview. So far I have done the following with the datagridview control... 1. I set "AllowDrop" to true. 2. In the DragEnter event I put this...
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 application (actually in C#) called from a third party piece of software via VBScript. The VB script passes an object as a parameter which my application applies changes to. My C# application dynamically creates a form, which includes controls...
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: 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,...
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: 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: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.