473,503 Members | 11,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.getElementById(txtid) has no properties error

I need to retrieve some notes from a database, allow users to modify
them and then return them to the database.I have done this
satisfactorily using php.However I would like to do it using AJAX.

To this end I have a <divthe innerhtml for which is sent from a php
file. The innerhtml constructs and fills a series of textareas and
provides each with an id.

When I want to return the modified note to the database and try to
copy the text displayed in a text area with the line

var txt=document.getElementById(txtid).value;
or
var txt=document.getElementById(txtid).text;

I get the error
document.getElementById(txtid) has no properties

When I try
var txt=document.getElementById(txtid);
txt gets the null value.

I would be grateful if someone could explain the basis of my error and
how I can get the text string back out of these text areas.

TIA

N
Mar 31 '07 #1
4 6304
noddy wrote on 31 mrt 2007 in comp.lang.javascript:
I need to retrieve some notes from a database, allow users to modify
them and then return them to the database.I have done this
satisfactorily using php.However I would like to do it using AJAX.

To this end I have a <divthe innerhtml for which is sent from a php
file. The innerhtml constructs and fills a series of textareas and
provides each with an id.

When I want to return the modified note to the database and try to
copy the text displayed in a text area with the line

var txt=document.getElementById(txtid).value;
or
var txt=document.getElementById(txtid).text;

I get the error
document.getElementById(txtid) has no properties

When I try
var txt=document.getElementById(txtid);
txt gets the null value.
var txt=document.getElementById('txtid');
>
I would be grateful if someone could explain the basis of my error and
how I can get the text string back out of these text areas.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 31 '07 #2
On 31 Mar 2007 11:21:34 GMT, "Evertjan."
<ex**************@interxnl.netwrote:
>noddy wrote on 31 mrt 2007 in comp.lang.javascript:
>I need to retrieve some notes from a database, allow users to modify
them and then return them to the database.I have done this
satisfactorily using php.However I would like to do it using AJAX.

To this end I have a <divthe innerhtml for which is sent from a php
file. The innerhtml constructs and fills a series of textareas and
provides each with an id.

When I want to return the modified note to the database and try to
copy the text displayed in a text area with the line

var txt=document.getElementById(txtid).value;
or
var txt=document.getElementById(txtid).text;

I get the error
document.getElementById(txtid) has no properties

When I try
var txt=document.getElementById(txtid);
txt gets the null value.

var txt=document.getElementById('txtid');
I should have pointed out the txtid is a variable name
after:
var txt=document.getElementById('txtid');
txt == null

Mar 31 '07 #3
noddy wrote on 31 mrt 2007 in comp.lang.javascript:
>>When I try
var txt=document.getElementById(txtid);
txt gets the null value.

var txt=document.getElementById('txtid');
I should have pointed out the txtid is a variable name
after:
var txt=document.getElementById('txtid');
txt == null
You must have made a coding mistake.
What about debugging?
Did you really do some simple testing yet?

<textarea id='txtid'>
blah
</textarea>

<script type='text/javascript'>

var txt=document.getElementById(txtid);

alert(txtid); // undefined
alert(txt); // null

var txtid = 'txtid';
var txt=document.getElementById(txtid);

alert(txtid); // txtid
alert(txt); // [object]
alert(txt.value); // blah
alert(txt.text); // undefined

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 31 '07 #4
On 31 Mar 2007 14:59:59 GMT, "Evertjan."
<ex**************@interxnl.netwrote:
>You must have made a coding mistake.
What about debugging?
Did you really do some simple testing yet?
Many thanks for your help.
Your debugging tips put me on the right track.
It resolved itself to an issue with innerHTML.
The solution to my problem is

document.getElementById(txtid).innerHTML

In IE7 this returns the text as modified.
IN FF it returns only the original text, but this is not a problem as
the only browser we will be using is IE7.

N
Apr 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3302
by: Crimefighter | last post by:
I'm not a javascript guy, but the use of this banner rotator script has given me fits. I know a few causes of the problem thus far, one being the layer tags aren't supported under Netscape 7.1...
3
9241
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
20
6929
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
1
2297
by: rajesh | last post by:
var fixedX = -1 // x position (-1 if to appear below control) var fixedY = -1 // y position (-1 if to appear below control) var startAt = 0 // 0 - sunday ; 1 - monday var showWeekNumber =...
5
4414
by: HopfZ | last post by:
I made two shortcut functions for document.getElementById as: function EBI2(id){return document.getElementById(id)}; var EBI3 = document.getElementById; But EBI3 don't work. EBI2('myText');...
2
2514
by: noddy | last post by:
In both IE7 and FF2(using firebug) I get the same error. I have a page that displays work contacts' details within a <DIV class = "contactBase" >. The div has a header area <div...
4
2605
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
13
4914
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
29
19141
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.