473,493 Members | 4,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

getElementByID value

I have this tag:

<span id="member_id"></span>

and I want to change the value to "Member"

why can't I do:

document.getElementByID("member_id").value = "Member";

Any help is appreciated.

Mike

Jul 20 '05 #1
4 150488
or it is:

document.getElementByID("member_id").innerHTML = "Member";

Michael Hill wrote:
I have this tag:

<span id="member_id"></span>

and I want to change the value to "Member"

why can't I do:

document.getElementByID("member_id").value = "Member";

Any help is appreciated.

Mike


Jul 20 '05 #2
or it is:

document.getElementByID("member_id").innerHTML = "Member";

Michael Hill wrote:
I have this tag:

<span id="member_id"></span>

and I want to change the value to "Member"

why can't I do:

document.getElementByID("member_id").value = "Member";

Any help is appreciated.

Mike


Jul 20 '05 #3
In article <3F***************@ram.lmtas.lmco.com>,
hi****@ram.lmtas.lmco.com enlightened us with...
I have this tag:

<span id="member_id"></span>

and I want to change the value to "Member"

why can't I do:

document.getElementByID("member_id").value = "Member";


There is no value property to a span element.
I assume you want the text "Member" displayed in that span.

var e = document.getElementById("member_id");
var oTextNode = document.createTextNode("Member");
var oReplaceNode = e.childNodes(0);
oReplaceNode.replaceNode(oTextNode);

You could also use innerHTML, but I have heard it isn't cross-browser
enough. It would be

document.getElementById("member_id").innerHTML = "Member";

--
~kaeli~
Why do they sterilize the needles for lethal injections?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4
It's getElementById(), not getElementByID(), so it would be:

document.getElementById("member_id").innerHTML

But:

document.getElementById("member_id").appendChild(d ocument.createTextNode("Member"));

is more standards compliant. Please note that the line above is
only required when initially appending text to the empty span.
Once the text node exists, you only need to change it's value. If
you're certain that the span will always only contain a text
node, you could use something like:

if (document.getElementById("member_id").firstChild == null) {

document.getElementById("member_id").appendChild(d ocument.createTextNode("Member"));

} else {
document.getElementById("member_id").firstChild.no deValue =
"Something Else";
}

Michael Hill wrote:
or it is:

document.getElementByID("member_id").innerHTML = "Member";

Michael Hill wrote:
I have this tag:

<span id="member_id"></span>

and I want to change the value to "Member"

why can't I do:

document.getElementByID("member_id").value = "Member";

Any help is appreciated.

Mike


--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available
at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #5

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

Similar topics

1
2684
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
3
9239
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...
8
3754
by: david | last post by:
I have developed a web form by using visual Studio. My question is: (1) what is the problem? (2) what is right way to do it? In the form, there are labels with id: lblWear, lblColor, and...
21
2684
rrocket
by: rrocket | last post by:
This works great in IE, but does not do anything in FireFox... Any ideas of what could be wrong with it? I checked all of the values (in IE through alert statements since nothing shows up in...
9
2019
by: RobertTheProgrammer | last post by:
Hi folks, I've been struggling with this for a few hours and I'm hoping someone can help me out. On my GridView (with C# codebehind) I have a date entry field. To help users enter only valid...
3
60121
by: ll | last post by:
I'm working with the script below which works with FF but not with IE 7. To clarify, the part of the code which isn't working in IE 7 is putting the value of variable y in the "totalString" input...
2
2598
by: andersond | last post by:
I have a webpage that allows insurance agents to enter a group of trucks for an insurance policy. I want to keep track of the number of power units (tractors or trucks), the number of trailers and...
1
2215
by: vikD | last post by:
Hello, I'm really bad at javascript but I managed to get the code below to work in IE but firefox gives this error... Error: document.getElementById.formall is undefined Basically use the...
1
2188
by: Noorain | last post by:
i add row dynamiccaly but value doesn't pprint. please help me. My coding is as follow <HTML> <HEAD> <TITLE> Add/Remove dynamic rows in HTML table </TITLE> <SCRIPT...
0
7118
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
6980
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...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3087
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
1397
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 ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
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.