defining and accessing js objects.

  • Thread starter Terry A. Haimann
  • Start date
T

Terry A. Haimann

First of all be kind, I am new to javascript.

In the following page, can you tell me if I have defined the ObjTyp and
the ObjTypeCnt incorrectly. And if that is correct, why can't they be
seen from within my function ChangeSearch? Yes, the ObjTyp and ObjTypeCnt
are generated by a php script.

Thx in advance, Terry


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script LANGUAGE=JavaScript>
var ObjType = new array(
"Binary",
"Emis",
"Gal",
"Glob",
"Open",
"Open&Ems",
"Plan",
"Planet",
"SuprNovRem",
"");
var ObjTypeCnt = 9;


function ChangeSearch(srchstr)
{

i = document.SrchForm.SearchDB.value;
alert('Testing 1... ' + document.SrchForm.SearchDB.value)
// alert('Testing 2... ' + document.SrchForm.SearchDB.options.text)
if (i==2)
{
j = 0;
alert("ObjTypeCnt = " + ObjTypeCnt);
while (j < ObjTypeCnt)
{
var myNewOption = new option(j+1, ObjType[j]);
document.SrchForm.DetailDB.options[0] = myNewOption;
alert("j = " + j);
j++;
}
}
}

</SCRIPT>
<title>Astronomy Page</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
</head>
<body>

<div align="center"><big><big><big><big><big>Terry's Astronomy Page</big></big></big></big></big><br>
<form NAME=SrchForm>

<select NAME="SearchDB"
onChange="ChangeSearch()">
<option VALUE=0 SELECTED> Search By
<option VALUE=1>Object
<option VALUE=2>Type of Object
<option VALUE=3>Photographer
</select>
<select NAME="DetailDB">
</select>
</div>
<br>
<br>
</form>
</body>
</html>
 
L

lallous

Hi,

A quick look at your code reveals some syntax typos:

array is different than 'Array' so change to 'Array'.
Same applies for 'option' =>change to: 'Option'

--
Elias
Terry A. Haimann said:
First of all be kind, I am new to javascript.

In the following page, can you tell me if I have defined the ObjTyp and
the ObjTypeCnt incorrectly. And if that is correct, why can't they be
seen from within my function ChangeSearch? Yes, the ObjTyp and ObjTypeCnt
are generated by a php script.

Thx in advance, Terry


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script LANGUAGE=JavaScript>
var ObjType = new array(
"Binary",
"Emis",
"Gal",
"Glob",
"Open",
"Open&Ems",
"Plan",
"Planet",
"SuprNovRem",
"");
var ObjTypeCnt = 9;


function ChangeSearch(srchstr)
{

i = document.SrchForm.SearchDB.value;
alert('Testing 1... ' + document.SrchForm.SearchDB.value)
// alert('Testing 2... ' + document.SrchForm.SearchDB.options.text)
if (i==2)
{
j = 0;
alert("ObjTypeCnt = " + ObjTypeCnt);
while (j < ObjTypeCnt)
{
var myNewOption = new option(j+1, ObjType[j]);
document.SrchForm.DetailDB.options[0] = myNewOption;
alert("j = " + j);
j++;
}
}
}

</SCRIPT>
<title>Astronomy Page</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
</head>
<body>

<div align="center"><big><big><big><big><big>Terry's Astronomy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top