Posted on 2003-03-28
Medium Priority
Last Modified: 2010-05-19
When I try to use the following script I get an error that says
document.getElementById is not a function
I have looked this up and it appears that netscape 4.X does not support the
document.getElementById but unfortunately that is the version that I have to write my page for does anyone have a suggestion on a possible replacement for this code.
Also I am not even certain that this is the only error that I would receive once if that actually worked
This is a very nice script I found at http://www.xs4all.nl/~ppk/js/domform.html

Here is the code:

<script language="JavaScript" type="text/JavaScript">
var counter = 0;

function moreFields()
     var newFields = document.getElementById('readroot').cloneNode(true);
     newFields.id = '';
     newFields.style.display = 'block';
     var newField = newFields.childNodes;
     for (var i=0;i<newField.length;i++)
          var theName = newField[i].name
          if (theName)
               newField[i].name = theName + counter;
     var insertHere = document.getElementById('writeroot');

window.onload = moreFields;

<div id="readroot" style="display: none">
     <p class="hr"> </p>

     <input type="button" value="Remove review" style="font-size: 10px"

     <input name="cd_1" value="title">

     <select name="rankingsel_1">
          <option value="excellent">Excellent</option>
          <option value="good">Good</option>
          <option value="ok">OK</option>
          <option value="poor">Poor</option>
          <option value="bad">Bad</option>

     <textarea name="review_1">Short review</textarea>


<span id="writeroot"></span>

<input type="button" value="Give me more fields!" onClick="moreFields()">
<input type="button" value="Send form" onClick="alert('Fake submit')">

Question by:davidtrina
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Accepted Solution

ahosang earned 120 total points
ID: 8224222
No, it's a DOM script that won't be possible for NS4.x
That's the thing with NS 4.x it's obsolete!! You won't be able to do many of the powerful things you can so easily do with newer browsers.

Expert Comment

ID: 8225139
There are a couple of ways to replace this code for Netscape:
1. do the whole lot using a server-side script. Each time the user clicks the button, send the form to the script which then writes a new form for you.
2. do it using a frameset with dynamically written frames - have one frame containing the scripts to write out form elements, and buttons to prompt the user for action, and the other to display the form (written dynamically by the first frame using document.write()).

LVL 16

Expert Comment

ID: 10150094
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: ahosang {http:#8224222}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question