473,594 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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="javasc ript: makeBold('descr iption');"><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 "descriptio n". 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 1496
acoder
16,027 Recognized Expert Moderator MVP
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
4895
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 write ten words in the text-area, then I move the cursor at the beginning of the second word and activate the event (for example, click on a button): is there a way to know that the cursor is at the beginning of the second word?
25
2645
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 platform API call? I was able to do this in Windows with a Windows.h function, but I want to also do it on Linux/Unix as well. I won't ask for a Linux API call that positions the cursor, as that is
7
9046
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 VS.NET/C#/System.Windows.Forms.
1
5078
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 box by 1 if my cursor is in front of the decimal point. If the cursor is after the decimal point, I want to increment the value by 0.1. How do I accomplish this? Is there a way to find out the cusror position in the control relative to decimal...
0
502
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. private void textBox1_MouseMove(object sender, MouseEventArgs e) { Point p = textBox1.PointToClient(new Point(e.X, e.Y)); /* now what to do I do with Point to figure out the character position in the text box??? */
2
2132
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 go up by one each time the right arrow key was pressed. Thanks Much, Gene in NC
0
1340
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 inherits from ParentControlDesigner. Just for starters I wanted to try to change the mouse cursor if it fell
4
4665
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 and write the fields into strings of rows, I want to be able to put field1 in row1/column position1, field2 in row1/column position10,.....etc. I've included the basic code to write a string of text. I understand the process of how to write the...
1
9172
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 part: When our people click on a blank MaskedTextBox field, the cursor does not automatically go to the first "non-filled" mask value. For Example: Take the MaskedTextBox "___-___-___". When our people click the Text area, their cursor may stop...
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8372
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
8003
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
8234
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
5739
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
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1210
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.