Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select() method unsupported in Safari



>
> You just need to focus() before you select():
>

Thanks, Scott!  The select() method works now in
Safari.  I just needed some focus.  Perhaps more
coffee would help. :)


However your solution presents another problem.  I am
using a dropdown menu that could apply to several
different text fields depending on the context.  I am
using the select() method to emphasize the text that
will be changed.  I would like to select the text the
moment the dropdown menu is clicked (onmousedown
event), so that the user can abort if the wrong text
field has been selected.  But I can't seem to bring
focus to the text field if the dropdown menu is
selected.  Or can I?  What am I doing wrong?

In the modified code below, notice that the text is
not selected from the dropdown menu.
----------------------------------

<!--

<html>
<head>

<script type="text/javascript">
    function selectText()
    {
        document.getElementById("textField").focus();
        document.getElementById("textField").select();
    }
    
    function changeText(elem)
    {
        var mammal =
elem.options[elem.selectedIndex].value;
        document.getElementById('textField').value =
"The " + mammal + " is on the mat";
    }
</script>

</head>

<body>

    <form>
        <input size="40" type="text" id="textField"
value="The cat is on the mat" />
        <select id="timerPopup"
onmousedown="selectText()"
onchange="changeText(this)">
            <option value="cat">cat</option>
            <option value="bat">bat</option>
            <option value="rat">rat</option>
        </select>
    </form>

</body>
</html>

-->



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Select() method unsupported in Safari (From: Scott Reynen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.