473,785 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding text format like bold or italic to the TextArea

3 New Member
hi!
i'm using textarea to type the contents.
inwhich i need to make the text as italic


if i use the following code i'm not getting the italic text instead i'm getting the html tags like <i>text</i> around the text.

how can i rectify these problem.

give me some suggestion.

[HTML] <textarea rows="13" name="messages" cols="65" tabindex="5" style="border-style: solid; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1">

<input type="button" value="&nbsp;I& nbsp;" name="Italic" tabindex="7" style="border-style: solid; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1" onclick="insert Italic()">

[/HTML]



Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. function insertItalic()
  4. {
  5.  
  6.  
  7.  var str = document.selection.createRange().text;
  8. document.compose.messages.focus();
  9. var sel = document.selection.createRange();
  10.  
  11. sel.text=str.italics();
  12.  
  13. return;
  14.  
  15.  
Dec 5 '07 #1
5 19678
hash4sp
55 New Member
Hi !

try using css...font-style: italic...for the text..

cheers!
Dec 5 '07 #2
Thirunavukarasu
3 New Member
Hi !

try using css...font-style: italic...for the text..

cheers!

thanks for your reply..

I have used css like what u told to me and script also . It will change the italic for the whole textarea.But i couldn't make the particular text as italic. Even I can select a paricular text using selection.creat eRange() .Anybody please help me..



I have used the following script....

Expand|Select|Wrap|Line Numbers
  1.  
  2. function makeItalic()
  3. {
  4. var s= document.getElementById("it");
  5.  
  6. s.style.fontStyle="italic";
  7. }
  8.  


[HTML] <input type="button" onClick="makeIt alic()" value="italic">[/HTML]
Dec 5 '07 #3
mrhoo
428 Contributor
Each textarea has one style object.

To style individual elements you have to create them and move the textarea value.
Eg, a p or div element and individually styled spans or inline elements containing the text.
Dec 5 '07 #4
Thirunavukarasu
3 New Member
hi!

can u please explain with one example
Dec 6 '07 #5
hash4sp
55 New Member
hi!

can u please explain with one example
As mrhoo said, try adding <span style=.....> before & after the text of createrange().. ..

cheers!
Dec 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1680
by: Lindsey | last post by:
Hi I am wondering if anyone can help. We have a form used by a client to add news to a database, however at the moment the text edited is bog standard and the user can not bold or color the text. I have seen in email applications such as hotmail and yahoo, that when you create a new email there is a menu above which when you highlight
1
3772
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
3
2468
by: gooderthanyou | last post by:
I have a textfield and you of course you can select text... When they hit the bold button I want it to obtain the selected text and bold it, the hard part is trying to figure out if javascript can even OBTAIN selected text?!?! I can do this in java if I have to, I know java better than javascript, it seems as that is the only way to do it from looking online. <-- me javascript beginner
3
6948
by: Adam Honek | last post by:
Hi, Is there any way to get text written in a richtextbox to convert into HTML or must we go about it the long way? Any other control support text entry then conversion to HTML? Thanks, Adam
6
7143
by: andreas | last post by:
A selected text has fontstyles like bold and italic and underscore I want to remove one of them without changing the other fontstyles. How to do that? Thanks for any response
2
3819
by: VB Programmer | last post by:
I have a gridview control with several data fields. When the user clicks 'edit' for the row I want the user to be able to edit a particular text field. Under that 'edit' textbox is a button. When they click on the button it fills in the textbox with some standard text. Question: In the code for the button how do I reference the textbox 'FreeTextBox1' (for the current edit row)? Here's the gridview layout...
0
3560
by: karen987 | last post by:
Could someone please tell me what code to add here? I have a weblog, with daily news which readers can add comments to, which are stored in a database. The form to add the comments is on an ASP page, (see code below). There is a small box, where readers can type a comment. What i want to do is to add a simple text editor, nothing too elaborate. A toolbar above the text area, should suffice, and it should be the same size as the box obviously. ...
16
11135
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might know one way or the other whether that was true or not, or could point me to an article or help text that would. What I have seen so far online and in Access 2007 help seems to confirm the above. But that (or at least (b)) seems incredible that it...
1
5326
by: cleary1981 | last post by:
Hi, I am trying to add page numbers to my document in xsl fo. I can get the page numbers to work but I need them to show at the bottom of each page. I know you can define an area as region-after but don't know how. Heres my xsl file so far. <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" ...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.