473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How can I position the cursor at a specific point from the end of a text area?

I have the following Javascript function on a page:

Expand|Select|Wrap|Line Numbers
  1. function makeBold(target) {
  2. document.getElementById(target).focus();
  3. document.getElementById(target).value=document.getElementById(target).value.concat('<b></b>');
  4. }
On the page is an image with this HTML:

[HTML]<a onclick="javascript: makeBold('description');"><img src="images/button_bold.gif" border="0"></a>[/HTML]

When I click on the button, the function makeBold() adds the HTML tags <b></b> to the end of a text area named "description". It also puts the cursor at the end of these tags. This is good, but what I really want to do is put the cursor between the beginning <b> tag and the end </b> tag. The idea is to make the text area resemble the fuctionality of Dreamweaver.

Is there any way I can set the position of the cursor between the tags? I think maybe some way to put the cursor at a specific distance from the end of the text area is the way to go, but I am not good enough at this.

Any help you can give would be appreciated! Thanks!
Nov 18 '07 #1
1 1481
acoder
16,027 Expert Mod 8TB
Introduction to Ranges should get you started.
Nov 19 '07 #2

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

Similar topics

3
by: PeP | last post by:
Good morning, I have a form containing a text-area, I'd like to know if it exists a function that, when I activate an event, returns the position of the cursor in the text-area. For example, I...
25
by: JeffS | last post by:
Honest, I scoured the comp.lang.c.faq for this but found nothing. :) Is there a library function for placing the cursor position in the console? Or is it something that can only be done with a...
7
by: Steve | last post by:
does any one know a way to determine the position of the cursor in a text box. I would like to position a list next to the current position for context commands. I am using...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
0
by: Jed Ozone | last post by:
In a TextBox, I'm using a MouseMove event to track the cursor position. I want to get able to tell what text the current cursor position is at so I can set the SelectionStart to that position. ...
2
by: Gene Hubert | last post by:
For a string that is being edited in a textbox, is there a way to find the position of the edit cursor in the string being edited? For example, it would be 0 or 1 at the beginning of a string and...
0
by: Andy Wynn | last post by:
Hello All, I've got a custom control ( Panel-like, but not inheriting from Panel) that has a header region that's custom drawn. Custom Control is using a custom controldesigner class that...
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
1
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
We have some dumb and lazy people here, so I need help. To fix the dumb part: We have placed MaskedTextBoxes on the forms so they will stop entering the information incorrectly. Now the lazy...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.