Solved

Full select text on gotFocus

Posted on 2004-10-13
4
251 Views
Last Modified: 2012-06-27
Hi.

How i can select all text into one textbox when the object got focus
0
Comment
Question by:Elvio Lujan
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:stumpy1
ID: 12300201


Say you have the following HTML in your aspx page. I am only
<HEAD>
<script language="javascript">
<!--
function test()
{
      Form1.TextSearch.select();
}
// -->
</script>
</HEAD>

...

<form id="Form1" method="post" runat="server">
      <asp:TextBox id="TextSearch" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 40px" runat="server" onfocus="test()">test</asp:TextBox>
</form>

Now when the textbox receives focus, the onfocus event is fired and the text in the textbox is selected
0
 
LVL 18

Author Comment

by:Elvio Lujan
ID: 12300544
ok.
but can i make one geheric function for all textboxes
0
 
LVL 5

Accepted Solution

by:
stumpy1 earned 50 total points
ID: 12300655
I think you should be able to change the test() function so that it dynamically takes the nameof the control that you want to work with as a parameter.

Eg. pseduo code

<HEAD>
<script language="javascript">
<!--
function test(ctl)
{
     Form1.ctl.select();
}
// -->
</script>
</HEAD>

...

<form id="Form1" method="post" runat="server">
     <asp:TextBox id="Text1" runat="server" onfocus="test(Text1)"></asp:TextBox>
     <asp:TextBox id="Text2" runat="server" onfocus="test(Text2)"></asp:TextBox>
     <asp:TextBox id="Text3" runat="server" onfocus="test(Text3)"></asp:TextBox>
     <asp:TextBox id="Text4" runat="server" onfocus="test(Text4)"></asp:TextBox>
</form>
0
 
LVL 18

Author Comment

by:Elvio Lujan
ID: 12301369
Ok man thanks...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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