Solved

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

Posted on 2002-07-11
10
787 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
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…
The viewer will learn how to dynamically set the form action using jQuery.

808 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