Solved

Use client-side VB to move cursor to end of input field in IE when page loads.

Posted on 2002-07-11
10
788 Views
Last Modified: 2007-12-19
I want to use clientside VB script to place the text cursor at the end of a text entry in an input field in IE5 when the page first loads.
The input field will be loaded with default text which the user will be required to ADD to. The existing text should NOT be selected.
0
Comment
Question by:rosstomlyn
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Accepted Solution

by:
Aristippus earned 100 total points
ID: 7148509
The following works for me:


<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
  Sub PlaceCursor()
      document.form1.txtField.value="Place Cursor Here >"
  End Sub
</SCRIPT>
</HEAD>
<BODY onload="PlaceCursor()">
<form name="form1">
<input type="text" name="txtField" value="">
</form>
</BODY>
</HTML>

Writing the value of the input field on the onLoad event will place the cursor at the point you want by default. If you have several onLoad subs, ensure that this one is called last.

Hope this helps.
0
 

Expert Comment

by:Pirado
ID: 7148879
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
 Sub PlaceCursor()
      document.form1.txtField.focus()
      document.form1.txtField.value="Place Cursor Here >"   
 End Sub
</SCRIPT>
</HEAD>
<BODY onload="PlaceCursor()">
<form name="form1">
<input type="text" name="txtField" value="">
</form>
</BODY>
</HTML>
0
 
LVL 1

Expert Comment

by:Aristippus
ID: 7149498
Pirado,

Setting the focus to the input field before writing the value to it is a little redundant. Focus is set to the control through the process of setting the value.

Proper etiquette on the site here is to submit comments and not locking the question, especially when the proposed answer is a copy and paste of a previous comment.

Aristippus
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Expert Comment

by:Pirado
ID: 7149697
Aristippus

He forgives me, I had not read correctly and thought that its commentary was the question...
You have all reason...
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7154365
Rejected per request ...

** Mindphaser - Community Support Moderator **
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7159791
try this, i don't know how but it wors fine.
T.P.
<HTML>
<head>
<script language=vbscript>
sub fnCursor()
    document.all.item("txt1").value = "Select"
    Dim docText
    set docText = document.all.item("txt1").createTextRange
    document.all.item("txt1").focus()
    document.all.item("txt1").value = docText.text
End Sub
</script>
</HEAD>
<BODY onload="fnCursor()">
<FORM name=frm>
<input type=text name=txt1 id=txt1><br>
</FORM>
</BODY>
</HTML>
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7162209
please comment.

T.P.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7271218
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7403624
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to Aristippus

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7431481
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question