Getting text out of a textarea

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I dont want the 1's and 0's in a textarea.... how can I get this to show in the normal line of text.
You mean an input/text field/form control? A textarea is a different form control than what you're using. To change the text in another kind of element, you can get a text node child of the element and assign to the text node's nodeValue property:

HTML:
<span id="display">0xDEADBEEF</span>
<script type="text/javascript">
  display = document.getElementById("display");
  display.firstChild.nodeValue = '0xCAFEBABE';
</script>

Note that if #display were initially empty, the above wouldn't work because #display wouldn't have any text node children.

An alternative is to leave the text input and style it so that it's indistinguishable from the surrounding text:
HTML:
<input id="display" value="10010110101000" size="14" />
<style type="text/css">
#display {
  background-color: transparent; /* may not work on some versions of IE */
  border-width: 0px;
}
</style>
 
Last edited:
Top