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!

Render HTML tag inside a text field?

Status
Not open for further replies.

ValeSyde

Programmer
Feb 13, 2004
1
US
If I send the string &quot;<B>This is a test</B>&quot; to a text field is it possible to have it displayed as This is a test rather than <B>This is a test</B>
 
i think that you set te text in a string and use innerhtml. something like this
 
If your code didn't show up you've probably got Process TGML ticked at the bottom of the screen Virusdoder
 
You could just set the text value, and then set the font-weight:


Code:
document.forms['formName'].textBoxName.style.fontWeight = 'bold';

OR:

Code:
document.getElementById('textBoxId').style.fontWeight = 'bold';

Hope this helps,

Dan
 
Code:
<script>
function postit()
{
var a = new Array(3)
a[0]=&quot;test1&quot;
a[1]=&quot;test2&quot;
a[2]=&quot;test3&quot;

var x=0;

for(x=0; x<3; x++)

{
document.alpha.txt.value = &quot;<b> + a + </b>&quot;;
}
</script>

<body>
<form name=&quot;alpha&quot;>
<textarea cols=20 rows=20 name=&quot;txt&quot;></textarea>
</form>
</body>


not tested see if it works.....

 
Sounds to me like ValeSyde wants wysiwyg,


<div contenteditable=&quot;true&quot; style=&quot;height:100px;width:100px;border:2px groove blue;&quot; id=&quot;rtf&quot;>Type something, select it and hit cntrl+B</div>


<script>
window.onsubmit = move;

function move(){
document.getElementById('text').value = document.getElementById('rtf').innerHTML;
}
</script>

----------
I'm willing to trade custom scripts for... [see profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top