<input ... onfocus="autoSelect(this)">

function autoSelect(el){
    if (el.value.length > 0) {
            el.selectionStart=0;
            el.selectionEnd = el.value.length;
    }
}


On the iPad (I don't have an iPhone) this code, though it does not display
the select-highlighting, will select any existing text in the input if you
visit the input by using the Previous|Next buttons on the virtual keyboard;
then, when you start typing, any existing text will be replaced; however, if
you touch the input element before you type a character, the caret will be
positioned wherever your fingertip has placed it, and any typed text will be
inserted or appended as the case may be.

I'm new to the iPad so I don't know yet how to get the highlighting. The
text inputs are giving me hassles because of all the bells and whistles
Apple has attached to them (magnifying glass, selection box, font-enlarging
tap, etc). It doesn't seem possible for the developer to trap the touchstart
event on a text-input.

Regards
Tim Romano
Swarthmore PA

On Wed, Jul 28, 2010 at 1:09 AM, Alex Zylka <[email protected]> wrote:

> My bad. (facepalm)
>
>
> On Jul 28, 2010, at 12:05 AM, Jesse MacFadyen <[email protected]>
> wrote:
>
> That gives the input focus and shows the keyboard, but I think the task was
> to select the text in the input field.
>
> Sent from my iPhone
>
> On 2010-07-27, at 1:21 PM, Alex Zylka < <[email protected]>[email protected]>
> wrote:
>
> Here's an example using focus():
> <form action="" method="" id="form" class="panel">
> Your first name: <input name="fname" id="fname">
> <br> <a class="whiteButton"
> href="javascript:document.getElementById('fname').focus();">Start Typing</a>
> </form>
>
> document.getElementById('fname').focus() is the way to go.
>
> Alex Zylka
> <http://www.zylka.us/> <http://www.zylka.us/>http://www.zylka.us/
>
> On Tue, Jul 27, 2010 at 1:41 PM, Krishna < 
> <[email protected]><[email protected]>
> [email protected]> wrote:
>
>> Hi J,
>> I need to implement the same functionality and have been searching for
>> a solution. If you figured this out, can you post the solution.
>> Thanks.
>>
>> On Jul 24, 3:00 pm, J Coppedge <[email protected]> wrote:
>> > How do you autoselectdata already in input field onfocus/click/
>> > tap?  I've tried the standard this.select() but doesn't seem to work
>> > on the touch interface - is it possible?  Have multiple input fields
>> > of values and would like the option for user to just enter an entirely
>> > new number without having to backspace orselectthe current text.
>> >
>> > Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "iPhoneWebDev" group.
>> To post to this group, send email to 
>> <[email protected]><[email protected]>
>> [email protected].
>> To unsubscribe from this group, send email to
>> <iphonewebdev%[email protected]><[email protected]>
>> [email protected].
>> For more options, visit this group at
>> <http://groups.google.com/group/iphonewebdev?hl=en><http://groups.google.com/group/iphonewebdev?hl=en>
>> http://groups.google.com/group/iphonewebdev?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To post to this group, send email to <[email protected]>
> [email protected].
> To unsubscribe from this group, send email to
> <[email protected]>
> [email protected].
> For more options, visit this group at
> <http://groups.google.com/group/iphonewebdev?hl=en>
> http://groups.google.com/group/iphonewebdev?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/iphonewebdev?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<iphonewebdev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/iphonewebdev?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.

Reply via email to