|
|
|
|
![]() ![]() |
Mar 4 2007, 05:25 PM
Post
#1
|
|
|
Super Member Group: [HOSTED] Posts: 693 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
I am working on a web "application" thing that allows you to click a button to add text to a textarea.
Similar to this forum when you click the BOLD button and it puts in {b}{/b} with the square brackets. I want a similar function like that. Also, I want it to add wherever the cursor is, not at the end. And after adding the thing, the cursor should be in between the tag or whatever that was added. All the extra stuff are extra priorities. For now I would like to get something that inserts text on click. The thing I came up with is: HTML <html> <head> <script type="text/javascript"> function write() {document.form.textarea.value = "This is the stuff that goes into the textarea";} </script> </head> <body><textarea id="txt1">Hello world....This is a text area</textarea></body> </html> I know that isn't right, so I need more help on this. |
|
|
|
Mar 5 2007, 06:19 AM
Post
#2
|
|
|
Super Member Group: [HOSTED] Posts: 760 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
I am working on a web "application" thing that allows you to click a button to add text to a textarea. Similar to this forum when you click the BOLD button and it puts in {b}{/b} with the square brackets. I want a similar function like that. Also, I want it to add wherever the cursor is, not at the end. And after adding the thing, the cursor should be in between the tag or whatever that was added. All the extra stuff are extra priorities. For now I would like to get something that inserts text on click. The thing I came up with is: HTML <html> <head> <script type="text/javascript"> function write() {document.form.textarea.value = "This is the stuff that goes into the textarea";} </script> </head> <body><textarea id="txt1">Hello world....This is a text area</textarea></body> </html> I know that isn't right, so I need more help on this. I view this kind of script in many sites and it is not difficult to code, so try this: HTML <html> <head> <script type="text/javascript"> function mywrite() { form.txt1.focus(); form.txt1.value = "This is the stuff that goes into the textarea"; } </script> </head> <body> <form name="it"> <input onclick="mywrite()" type="button" value="add text" title="add text to text area"> <textarea id="txt1" name="txt1"></textarea> </form> </body> </html> As you can see, it is a basic and very simple version, for a start is enough Best regards, |
|
|
|
Oct 31 2007, 05:14 AM
Post
#3
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
I am working on tiff image, I want to draw a rectangle on tiff image to highlight the some part of image. I have loaded tiff image in the browser using embed tag and used tiff plug ins. can you please help me? how to draw the rectangle with transparent color to highlight the part of image? thanks
-Amol |
|
|
|
Mar 4 2008, 01:29 PM
Post
#4
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
text editor
Add Text To Textarea How can I write content of a variable in javascriptt that I have fetched from database through php -reply by rajesh |
|
|
|
Mar 5 2008, 04:22 AM
Post
#5
|
|
|
Premium Member Group: [HOSTED] Posts: 391 Joined: 16-February 06 From: Kolkata, India Member No.: 11,322 |
text editor Add Text To Textarea How can I write content of a variable in javascriptt that I have fetched from database through php -reply by rajesh Thats not difficult at all. Just substitute the variable for the message. For example, if myVar is your variable containing the database result and you want it to be displayed in the textarea with the ID txt1. CODE document.getElementById('txt1').value = myVar;
|
|
|
|
Mar 5 2008, 04:56 AM
Post
#6
|
|
|
Super Member Group: [HOSTED] Posts: 693 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
Is there a way to control where the cursor is by means of moving it through a number of characters of the text inserted?
|
|
|
|
Mar 5 2008, 11:47 AM
Post
#7
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
Is there a way to control where the cursor is by means of moving it through a number of characters of the text inserted? There are ways, though I don't have time to write it up. You'll need to investigate createTextRange and SelectionStart, you'll need to use both to make it more compatible, so test for each object before using it. Cheers, MC |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th October 2008 - 06:46 PM |