?
Solved

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

Posted on 2002-07-11
10
Medium Priority
?
791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Accepted Solution

by:
Aristippus earned 400 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
How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
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 demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Suggested Courses

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