Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2004
    Location
    Norway
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Catching change of value, set by popup window

    I have a main window. On this window, I have a field. To the right of this field, I have a button. This buttons opens a window (window.open) which is a calendar. This let's me select a date. When so, this value is returned to the parent, in the mentioned field. This works nicely. Now, what I would like to do, IN THE MAIN WINDOW, is to catch if the value of this field has changed. If the field is blank before the user clicks the button and selects a value, which again is populated to the field, I want to catch this. I have tried to use the onChange event of the field, but nothing happens. I do not want to do this as part of the popupwindow, because this is a generic window which is used throughout the application.

    Anyone?

    Best regards,
    Rune Carlsen

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,950
    Thanks
    0
    Thanked 236 Times in 233 Posts
    I'm sure the popup calendar has the handle of the destination field. Can't you add some code to it?

    objDest.focus();
    objDest.value = date;
    objDest.blur();

    It won't hurt other pages that use that calendar.

    Then in the field, set an onblur and an onfocus handler
    Code:
    <input type="text" name="date" onblur="checkValue(this)" onfocus="setValue(this)" />
    <input type="button" value="..." onclick="openCal(this.form.date)" />
    ...
    var origValue;
    function openCal(targetField){
       var w = window.open(...); //open calendar
       w.focus();
    }
    
    function checkValue(el){
       if (el.value!=origValue){
           alert("The field has changed!");
           //do something
       }
    }
    
    function setValue(this){
       origValue = this.value;
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •