[Javascript] I Need an Object
Steve
extstarrfam at cox-internet.com
Mon Apr 15 00:23:07 CDT 2002
I wrote this code earlier to help someone else. Now I
am caught up in how to make the page work that is
created after the first selection is made. If I try to
use 'Step 1 Choices' on the page that is created using
javascript, I get an error message of "Object Needed"
and the DOCTYPE definition is highlighted. I have been
trying in vane to figure it out. Does any one have a
solution. Here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--Written by Stephan Starr extstarrfam at
cox-internet.com-->
<!--Alter according to your needs-->
<title>Parent List to Child List Display
Options</title>
<script language="javascript 1.2"
type="text/javascript">
<!--
function process(n) {
if(n==0) alert("no choice made");
if(n==1) choiceOne();
if(n==2) choiceTwo();
if(n==3) choiceThree();
}
function choiceOne( ) {
alert("Rocks");
parentSelection( );
this.document.write('<form name="choices"><select
name="child">');
this.document.write('<option value="0" selected>Step 2
Choices');
this.document.write('<option value="1">Limestone');
this.document.write('<option value="2">Granite');
this.document.write('<option value="3">Sandstone');
this.document.write('</select>');
}
function choiceTwo( ) {
alert("Woods");
parentSelection( );
document.write('<form name="choices"><select
name="child">');
this.document.write('<option value="0" selected>Step 2
Choices');
this.document.write('<option value="1">Oak');
this.document.write('<option value="2">Walnut');
this.document.write('<option value="3">Ash');
this.document.write('</select>');
}
function choiceThree( ) {
alert("Waters");
parentSelection( );
this.document.write('<form name="choices"><select
name="child">');
this.document.write('<option value="0" selected>Step 2
Choices');
this.document.write('<option value="1">Fresh Water');
this.document.write('<option value="2">Salt Water');
this.document.write('<option value="3">Hard Water');
this.document.write('</select>');
}
function parentSelection( ) {
//childWindow = window.open('', '', 'width=300,
height=300');
//window.document.write('<html><body>');
window.document.write('<form name="choices"><select
name="parent" onChange="process(value)">');
window.document.write('<option value="0">Step 1
Choices');
window.document.write('<option value="1">Rocks');
window.document.write('<option value="1">Woods');
window.document.write('<option value="1">Waters');
window.document.write('</select><br><br></form>');
//window.document.write('</body></html>');
//window.document.close( );
//window.focus( );
}
//-->
</script>
</head>
<body>
<form name="choices">
<select name="parent" onChange="process(value)">
<option value="0" selected>Step 1 Choices</option>
<option value="1">Rocks</option>
<option value="2">Woods</option>
<option value="3">Waters<option>
</select>
<!--The other selection and it's options are written
using JavaScript.-->
</form>
</body>
</html>
=====================
More information about the Javascript
mailing list