By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

defining and accessing js objects.

P: n/a
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[i].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>
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <te***@yngstr.oldboy.com> wrote in message
news:pa****************************@yngstr.oldboy. com...
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[i].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>

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.