p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   Getting id of a control in javascript (http://p2p.wrox.com/showthread.php?t=66103)

sudhir164 February 22nd, 2008 09:36 AM

Getting id of a control in javascript
 
Hi,

How to get the id of a control which has focus on it in javascript. the Id's are created dynamically so i will not be knowing the id at the start. On focus of a control i want to get the id of that control.

dparsons February 22nd, 2008 09:47 AM

What does this have to do with P2P feedback? You need to post this question in the Javascript forum.

The answer to your query is as follows:

    <script type="text/javascript" language="javascript">
    function alertBox (txt)
    {
        alert(txt.id);
    }
    </script>

       <input type="textbox" id="foo" name="foo" onFocus="alertBox(this);" />

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========

joefawcett February 23rd, 2008 05:35 AM

IE supports document.activeElement, I'm not sure it's part of the Mozilla/Gecko engine though.

--

Joe (Microsoft MVP - XML)


All times are GMT -4. The time now is 05:10 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.