Closed Bug 306784 Opened 19 years ago Closed 19 years ago

document.getElementById(elementName).value has no properties

Categories

(Toolkit Graveyard :: Error Console, defect)

x86
Windows 2000
defect
Not set
major

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 174617

People

(Reporter: ozgwei, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

I have consulted Mozzila and document.getElementById(elementName) is the
recommended way to access a scriptable element but this code fails in Firefox.
It works in IE6.

Following is the code:
Code:
<input type="text" name="code" maxlength="10" size="10" value=""
onchange="javascript:changeInnerHTML('name','');getName();">

Name:
<span id="name" class="generalText"></span>

<script language="JavaScript" type="text/javascript">
<!--
function getName() {
    var url = "/getNameXml.do" + "?code=" +
escape(document.getElementById("code").value);
    initRequest();
    req.open("GET", url, true);
    req.onreadystatechange = receiveName;
    req.send(null);
}

Note that the input element is very simple and of course it's inside a form.
The javascript function is copied from some most reputable sources such as sun
and apple.

Javascript console reports:
Error: document.getElementById("code") has no properties
Source File: ...


Reproducible: Always

Steps to Reproduce:
1. copy the code above and make into a html file.
2. start the html file
3. enter something in the "code" field and move the cursor out of the field.
4. nothing happens. (in a proper application, the name field should be displayed
with the name retrieved from the server)
5. open javascript console and find the error.

Actual Results:  
Javascript console reports:
Error: document.getElementById("code") has no properties
Source File: ...


Expected Results:  
No errors.

The javascript is copied from the following websites:

http://java.sun.com/developer/technicalArticles/J2EE/AJAX/

https://bpcatalog.dev.java.net/nonav/solutions.html

*** This bug has been marked as a duplicate of 174617 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Product: Firefox → Toolkit
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.