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

    Join Date
    Apr 2004
    Rep Power

    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
    Rep Power
    here is an example of how you do that:

    <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;
    <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">
    <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