School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,167 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,528 people online right now. Registration is fast and FREE... Join Now!




Formatting a textfield

 

Formatting a textfield

svengebr

25 Sep, 2007 - 12:01 PM
Post #1

New D.I.C Head
*

Joined: 25 Sep, 2007
Posts: 2


My Contributions
Hello! Is there anyway to format the content a text field using Javascript. Would like to create a boldfaced headline, some spaces and the rest of the text. Any help appreciated!

Code here...:

CODE
if (objSakstype.value==1) {obj.value = "Here is where I would like to put the formatted text";}


User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 3)

axel

RE: Formatting A Textfield

25 Sep, 2007 - 01:12 PM
Post #2

Bug Juice Doesn't Come in a Jar
Group Icon

Joined: 31 Dec, 2006
Posts: 1,937



Thanked: 2 times
Dream Kudos: 100
My Contributions
I don't know about JavaScript, but why not just use CSS? It is much easier just to define certain classes.
User is offlineProfile CardPM
+Quote Post

supersssweety

RE: Formatting A Textfield

26 Sep, 2007 - 07:33 AM
Post #3

D.I.C Regular
Group Icon

Joined: 16 Mar, 2007
Posts: 340



Thanked: 3 times
Dream Kudos: 125
My Contributions
[quote name='svengebr' date='25 Sep, 2007 - 01:01 PM' post='260006']
Hello! Is there anyway to format the content a text field using Javascript. Would like to create a boldfaced headline, some spaces and the rest of the text. Any help appreciated!

Code here...:

CODE
if (objSakstype.value==1) {obj.value = "Here is where I would like to put the formatted text";}

[/quote]

I don't know much javascript either, but if it were me I would see what happend when I put tags around it like so:

CODE
if (objSakstype.value==1) {obj.value = "<h3>Here is where I would like to put the formatted text</h3>";}

[/quote]

and then format the h3 tags w/ css
User is offlineProfile CardPM
+Quote Post

supersssweety

RE: Formatting A Textfield

26 Sep, 2007 - 07:46 AM
Post #4

D.I.C Regular
Group Icon

Joined: 16 Mar, 2007
Posts: 340



Thanked: 3 times
Dream Kudos: 125
My Contributions
don't think that works though...how will you be using obj.value? you could:

CODE

document.write("<H3>"+obj.value+"</H3>");


http://www.java2s.com/Code/JavaScript/Deve...nJavaScript.htm
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:31PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month