Solved

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

Posted on 2002-07-11
10
785 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

932 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

11 Experts available now in Live!

Get 1:1 Help Now