View Full Version : Catching change of value, set by popup window

Rune Carlsen
06-10-2004, 09:16 AM
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.


Best regards,
Rune Carlsen

06-10-2004, 09:58 AM
I'm sure the popup calendar has the handle of the destination field. Can't you add some code to it?

objDest.value = date;

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

Then in the field, set an onblur and an onfocus handler

<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

function checkValue(el){
if (el.value!=origValue){
alert("The field has changed!");
//do something

function setValue(this){
origValue = this.value;