• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1193
  • Last Modified:

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.
0
mock5c
Asked:
mock5c
  • 2
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
The calendar likely renames the field. Look in the documentation and add the code to something like onselect
0
 
mock5cAuthor Commented:
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?
0
 
Michel PlungjanIT ExpertCommented:
Onchange is not triggered from script unless you trigger it specifically
As I said: go to the documentation of Tigra or their forum



http://www.softcomplex.com/forum/viewthread_5416/
0
 
mock5cAuthor Commented:
I discovered that I had an ancient version of Tigra calendar.  So after updating and reading the forum link, everything has been resolved.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now