Computing.Net > Forums > Programming > javascript problem

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

javascript problem

Reply to Message Icon

Original Message
Name: monish_career
Date: November 24, 2005 at 01:26:36 Pacific
Subject: javascript problem
OS: windows xp
CPU/Ram: p-4/512
Comment:

1. there is a text which is calling a function on onclick() of the text. The function generates a number and then puts it in the text but the cursor is at the start of the value in the text box . I want that this cursor(control) should be at the end of the value that gets populated in the text box so that i can delete it by using back space. Can anybody tell me how to proceed for this problem.


Report Offensive Message For Removal


Response Number 1
Name: Michael J (by mjdamato)
Date: November 25, 2005 at 11:26:51 Pacific
Reply:

Here's an example that should get you going:

function doField(field) {
field.value="Populated Value";
fieldTxt = field.createTextRange();
fieldTxt.moveStart( "character", field.value.length );
fieldTxt.moveEnd( "character", 0 );
fieldTxt.select();
}


you can do much more with this as well. If you were to use (field.value.length-2) as the moveStart value then the function woud always select the last two characters in the text field.

See this page for reference: http://www.daniweb.com/techtalkforums/thread15182.html.

Pretty funny, but I just realized that the person who answered to post in that other forum I reference above is someone I used to work with!

Michael J


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home



Results for: javascript problem

javascripting problem\question ?
    Summary: okay this is a page i've got that will adjust the virtual memory setting of a machine over the corporate network .. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML> <HEAD> ...
www.computing.net/answers/programming/javascripting-problemquestion-/9109.html

Little javascript problem
    Summary: I have a little problem that I'm sure them that know will be able to sort out in a trice! I'm trying to write the value of a variable in formatted text on a html page which works OK except that the va...
www.computing.net/answers/programming/little-javascript-problem/8139.html

javascript problem with prompt()
    Summary: i am writign a javascript program and i want to store letters in an array. the letters are to be entered by the user via the propmt() function. when i enter letters they are not stored, however numb...
www.computing.net/answers/programming/javascript-problem-with-prompt/892.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History






Data Recovery Software