#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    488
    Rep Power
    12

    Get last field of focus


    Hi all.
    Let's say I have focus in a text field and then I click a link to open a poup window. Is it possible to pass the field name of last focus to that popup window??
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,116
    Rep Power
    119
    here is an example of how you do that:

    Code:
    <script type="text/javascript">
    function detectfocus(field)
    {
    document.getElementById("hiddenfield").value = field;
    var pulnk = document.getElementById("puwin").onclick = function()
    {
    if (field != undefined) 
    {
    window.open("popup.php?lastfocal="+field+"","popWin","width=400,height=300"); // add other directives as needed
    return false;
    }
    }
    }
    </script>
    
    <form method="post">
    <input type="text" name="txtfield1" onblur="detectfocus(this.name)"><br/>
    <input type="text" name="txtfield2" onblur="detectfocus(this.name)"><br/>
    <input type="text" name="txtfield3" onblur="detectfocus(this.name)"><br/>
    <input type="hidden" id="hiddenfield" name="lastfield">
    </form>
    
    <br/>
    
    <a id="puwin" href="#" onclick="return false">Open Pop Up Window</a>

    Comments on this post

    • nikko50 agrees : Thanks. I'll give it a try!

IMN logo majestic logo threadwatch logo seochat tools logo