473,395 Members | 2,423 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,395 software developers and data experts.

javascript and TextBox problem

To all,

I've got a problem using Javascript to control the properties of a html
textbox.
I was wondering if I could change the cursor index / position of the
text within a textbox object.

ie. for example the text of a textbox is "hello tom"; and I want to
shift the cursor's index to 6 which points at the letter "t" of the
word "tom"

by the way, I am also finding ways to selectively highlight the text of
a textbox, like I would like to highlight / select just the word "tom".

so is it possible??? or any alternatives???
From Jason (Kusanagihk)


May 8 '06 #1
5 1932
ku********@gmail.com wrote:
To all,

I've got a problem using Javascript to control the properties of a html
textbox.
I was wondering if I could change the cursor index / position of the
text within a textbox object.

ie. for example the text of a textbox is "hello tom"; and I want to
shift the cursor's index to 6 which points at the letter "t" of the
word "tom"

by the way, I am also finding ways to selectively highlight the text of
a textbox, like I would like to highlight / select just the word "tom".

so is it possible??? or any alternatives???


Range manipulation in Firefox is not well supported and buggy, to boot.
However, the way to move the caret and to select text is through
textarea.setSelectionRange(startPos, endPos). Find the current
position via textarea.selectionStart and textarea.selectionEnd. If the
two positions are different, then you have a selection, otherwise just
the caret. The corresponding IE operations are completely different.

Csaba Gabor from Vienna

May 8 '06 #2
Thx Csaba Gabor,

I think the javascript I'm writing must be workable on both mozilla and
ie6; so can you tell me about the handling on ie6 too?

thx
From Jason (Kusanagihk)


May 10 '06 #3
ASM
ku********@gmail.com a écrit :
Thx Csaba Gabor,

I think the javascript I'm writing must be workable on both mozilla and
ie6; so can you tell me about the handling on ie6 too?


is that works with your IE6 :
http://actuel.fr.selfhtml.org/articl...de/exemple.htm

doesnt' work with my IE Mac
but does with Fx and Safari

--
Stephane Moriaux et son [moins] vieux Mac
May 10 '06 #4
yup, not sure why Mozilla and IE can't stick to the same specifications
(eg. W3C's DOM spec).

I just found that parts of the javascript DOM model (eg. creating a
textbox using document.createElement ("input")) might need to set
different attributes to make that textbox object containing the same
appearance and behaviours on both browsers....

it is also kind of messy and troublesome in writing the javascript code
to be runnable on netscape 4.x and mozilla.... again, many different
methods or attributes have to be taken into concern....

May 19 '06 #5
ku********@gmail.com said the following on 5/19/2006 3:30 AM:
yup, not sure why Mozilla and IE can't stick to the same specifications
(eg. W3C's DOM spec).
Because IE has it's own specs. If those specs happen to agree with W3C,
then great. If they don't, it doesn't make one ounce of difference to MS.
I just found that parts of the javascript DOM model (eg. creating a
textbox using document.createElement ("input")) might need to set
different attributes to make that textbox object containing the same
appearance and behaviours on both browsers....
Example?

And what is "both browsers"? Would they be Camino and Konqueror? Or
Opera and ICEBrowser? Don't fall into the "two browser" trap.
it is also kind of messy and troublesome in writing the javascript code
to be runnable on netscape 4.x and mozilla.... again, many different
methods or attributes have to be taken into concern....


Who writes for NN4 anymore?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephen | last post by:
I've got this great wee function which strips out the spaces entered into a textbox and it does this on the key press off a user. I got this working in a test application no problem however when I...
5
by: John | last post by:
Hi, I have an asp.net form where if the user enters an incorect date I change the color of the textbox to red and also display a label field with a message saying the date is invalid. What I...
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
7
by: joey.powell | last post by:
I have a home page with username and password textboxes and a login button for purposes of users being able to log in (forms authentication) directly on the site home page. I also have a dedicated...
4
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
1
by: susmitha | last post by:
hai iam a fresher in .net.My problem is I have one javascript sourcefile and some javascript functions in my aspx page like shown below. <script language=javascript...
2
by: Phil | last post by:
Hi, There is a label and a textbox. There are two buttons: one HTML (buttonA), the other ASP.NET (ButtonB). Clicking on buttonA starts a javascript function, starting on ButtonB triggers...
6
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>'...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.