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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bold "<b>" Tag in Textarea of a Form 1

Status
Not open for further replies.

kennygadams

Programmer
Jan 2, 2005
94
US
Hello everyone,

Ive created a form that allows users to edit the sidebar of their site. Here is whats listed in the textarea of the form:

<A HREF=" Lessons</A>
<BR>
<BR>
Jodie Coston's free online photography course presented by MorgueFile. Learn the fundamentals of exposure, composition, lighting, filters
and lots more.
<BR>
<BR>
<BR>



With CSS, how can I make the HTML tags stand out in BOLD like this:

<A HREF="">Photography Lessons</A>
<BR>
<BR>
Jodie Coston's free online photography course presented by MorgueFile. Learn the fundamentals of exposure, composition, lighting, filters
and lots more.
<BR>
<BR>
<BR>



Thanks for your time.

Kenny Adams

Kenny Adams
 
I'm afraid that what you're wanting to do cannot be done with a <textarea>. It's either all or nothing:
Code:
<textarea style="font-weight:bold"></textarea>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Here's an alternative if you don't mind using a little javascript and having it show up 2 times on the screen. Note that this function is not foolproof by any means, and you might wanna use different temp characters if a big portion of your audience is hispanic - however, it worked fine for me for the few times I tested it.
Code:
<html>
<head>
<script type="text/javascript">

function updateDiv(str) {
   obj = document.getElementById("blah");
   //mark where bold tags will go with uncommon characters
   str = str.replace(/\<([^\<]+)\>/g, '<¡$1¿>');
   //take out all gt and lt to be displayed properly in the div
   str = str.replace(/\</g, "&lt;").replace(/\>/g, '&gt;');
   //insert bold tags
   str = str.replace(/\¡/g, '<span style="font-weight:bold; color:#ff0000">').replace(/\¿/g, '</span>');
   //insert line breaks
   str = str.replace(/\n/g, '<br>');
   obj.innerHTML = str;
}

</script>
</head>
<body>
   <div style="float:left">
      <textarea style="height:200px; width:350px" onkeyup="updateDiv(this.value)"></textarea>
   </div>
   <div id="blah" style="height:200px; width:350px; border:1px solid #000000; overflow:auto;"></div>
</body>
</html>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
kaht said:
I'm afraid that what you're wanting to do cannot be done with a <textarea>. It's either all or nothing:

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top