Solved

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

Posted on 2002-07-11
10
784 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now