We help IT Professionals succeed at work.
Get Started

JavaScript value from pop-up window

mock5c asked
Last Modified: 2012-08-20
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.
Watch Question
IT Expert
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE