Click to See Complete Forum and Search --> : Null or 'not an object' error message


janvanheerden
12-15-2002, 01:55 AM
Hello everybody,

I am new to the group and also new to JavaScript.

I am using FrontPage 2002 to design a web site. I have 4 pages and 2 of them have forms.
In the forms I ask for personal details which I send to a database. Everything works fine up to that point.

The problems start when I want to generate a unique reference number that consists of a surname, date and time.

I inserted the following script in the head section:

<script language = "JavaScript">
var date1 = new Date()
var mont = date1.getMonth() + 1 // To display the correct month
</script>

I inserted the following script into the input tag of the submit button:

<input type="submit" value="Submit" name="B1" onClick = "document.Clients.RefNo.value = document.Clients.Surname.value + date1.getDate() + mont + date1.getHours() + date1.getMinutes()" >

Where:
Clients - name of form
RefNo - name of textbox
Surname - name of textbox


I have a one page web (the Try page) where I try out script before I use it in the main site. The above works perfectly in the Try page.

When I insert the code into the main page, I get the following error message:

'document.Clients.RefNo' is null or not an object.

I have tried various other syntaxes without success. The only difference between the Try and main pages, is that Try only has one page and I use an ordinary button there to test the script.

I would appreciate it if somebody could put me on the right track.

Thanks,

Jan van Heerden
janvanheerden@worldonline.co.za
:confused:

ShrineDesigns
12-15-2002, 03:39 AM
try this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!--
var date = new Date();
var mont = date.getMonth() + 1;
var d = document;
function SetRefNo(){
d.Clients.RefNo.value = d.Clients.Surname.value + date.getDate() + mont + date.getHours() + date.getMinutes()
}
//-->
</script>
</head>
<body>
<form action="" method="get" name="Clients" onSubmit="SetRefNo()">
</form>
</body>
</html>