Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript modifying data user cannot access. How? 1

Status
Not open for further replies.

DWAlex

Programmer
Nov 28, 2011
3
US
In VB, I'd put a label on a form and update its .Text value to show a number or text to the user that they can't select or update.

How do I replicate this in client-side Javascript?

This is in a page described thusly:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
 
Exactly the same way, though you'll want to use the innerHTML property of the element.

Code:
document.getElementById('mylabel').innerHTML="Text to place inside label";

There are also innerText and innerContent properties, though they aren't as cross browser friendly as innerHTML


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Slight correction, its textContent not innerContent.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Sorry if I wasn't clear. This isn't XML, I'm looking for an HTML object I can update using client-side Javascript, which the user can see, but the user cannot edit.
 
My answer is not XML related, its straight HTML accessed through javascript.

The element can be pretty much any element including divs, spans, and yes even labels.

HTML:
<span id="mylabel"></span>

or

<label id="mylabel">
</label>

etc...

Pretty much any displayable html element has an innerHTML property you can set, and that can't be changed by the user directly.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
How excellent!

Not seeing the property listed in W3Schools after a short search, outside the XML pages.

But it works! Marvelous. Thanks so much, I'd have never found that myself!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top