Link to home
Start Free TrialLog in
Avatar of mock5c
mock5c

asked on

JavaScript value from pop-up window

This seems a bit trivial but it is not working for me.

I have a form with a text field and an icon next to it that, when clicked, launches a pop-up window for selecting a date from a calendar.  The calendar package is the Tigra Calendar javascript module.

After selecting a date the text field is populated with the date in yyyy-mm-dd format.

In some other javascript code, I would like to check that a date is chosen.  I simply want to check if the field has a value or not.  But for some reason, when I check this field in the code, it does not find the element value.  I set an alert(scan_date) but no alerts pop-up after choosing the date.  If I manually type in the date value in the field, it does get this value and the alert pops up.

For getting the value, I use this line:

var scan_date = document.getElementById("scan_date").value;

Open in new window


The PHP code is:
<input type=text id="scan_date" name="scan_date" value="<?php echo $scan_date;?>" class=input maxlength=10> <?php echo $flag;?>
<a href="javascript:cal1.popup();"><img src="img/cal.gif" width="16" height="16" border="0" alt="Click here to pick the date"></a>

Open in new window


After the form closing tag I have:

var cal1 = new calendar1(document.forms['addnew'].elements['scan_date']);
cal1.year_scroll = true;
cal1.time_comp = false;

Open in new window


I figured that's all the information that I need to put here for the experts to figure this out.  It seems that it should be pretty straightforward.
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

The calendar likely renames the field. Look in the documentation and add the code to something like onselect
Avatar of mock5c
mock5c

ASKER

When I select the value from the popup, the field is populated with the date.  This field is "scan_date".  I was hoping that since the field was populated via selecting from popup, this would trigger an onChange event and then the alert dialog would display the date that was selected.  This is not what happens.  This field does not seem to register an onchange event unless I were to manually enter the date in.

I just noticed that if I select a date from the popup and the scan_date field is populated, and then go to a different field with an onchange event and enter a value manually, the alert dialog for displaying the date will show the date I  previously just chose in the popup.  How can I make this so that this happens immediately after the date is chosen from the popup?
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mock5c

ASKER

I discovered that I had an ancient version of Tigra calendar.  So after updating and reading the forum link, everything has been resolved.