[Javascript] Object required, Line 0

Rodney Myers rodney at aflyingstart.net
Wed Apr 17 16:01:40 CDT 2002


Steve,

I believe that once you re-commence writing to the document that the
script objects within the document are no longer available.

Also to get the value the selected option  of a select from within the
select tag you can use this.value - but only if you are working in an
MSIE only world. The non browser specific way is
this.options[this.selectedIndex].value

hth

Rodney


Steve wrote:

> Will someone please help me understand what is needed
> to eliminate the 'Object required, Line 0' message.  If
> I remove the onChange="process(value)" from the
> "parent" selection it does not give the message but it
> is useless then.  I have reached a mental impasse and
> would appreciate some help with this.  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">');
>  //document.write('<option value="0A" selected>Step 2
> Choices');
>  this.document.write('<option value="1A">Limestone');
>  this.document.write('<option value="2A">Granite');
>  this.document.write('<option value="3A">Sandstone');
>  this.document.write('</select>');
>
> }
>
> function choiceTwo( ) {
>  alert("Woods");
>  //parentSelection( );
>  document.write('<form name="choices"><select
> name="child">');
>  //document.write('<option value="0A" selected>Step 2
> Choices');
>  document.write('<option value="1A">Oak');
>  document.write('<option value="2A">Walnut');
>  document.write('<option value="3A">Ash');
>  document.write('</select>');
> }
>
> function choiceThree( ) {
>  alert("Waters");
>  //parentSelection( );
>  document.write('<form name="choices"><select
> name="child">');
>  //document.write('<option value="0A" selected>Step 2
> Choices');
>  document.write('<option value="1A">Fresh Water');
>  document.write('<option value="2A">Salt Water');
>  document.write('<option value="3A">Hard Water');
>  document.write('</select>');
> }
>
> function parentSelection( ) {
>
>  document.write('<form name="choices"><select
> name="parent"onChange="process(value)">');
>  document.write('<option value="0">Step 1 Choices');
>  document.write('<option value="1">Rocks');
>  document.write('<option value="2">Woods');
>  document.write('<option value="3">Waters');
>  document.write('</select><br><br></form>');
> }
>
> function fill_Window( ) {
> // For process(n) I have tried using (value) and
> (this.document.choices.parent.value)
>  this.document.write('<form name="choices"><select
> name="parent" onChange="process(value)">');
>  this.document.write('<option value="0">Step 1
> Choices');
>  this.document.write('<option value="1">Rocks');
>  this.document.write('<option value="2">Woods');
>  this.document.write('<option value="3">Waters');
>  this.document.write('</select>');
>
>  this.document.write('<br><br><br>');
>  this.document.write('<select name="child">');
>  this.document.write('<option value="0A" selected>Set 2
> Choices');
>  this.document.write('</form>');
>
>  this.document.close( );
>  this.document.choices.parent.focus( );
> }
> //-->
> </script>
> </head>
> <body onLoad="fill_Window( )">
>
> </body>
> </html>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list