Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 22nd, 2003, 01:48 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default OnChange Event Doesn't Execute

Hi All!

I have a form with a Readonly text field for a date.
When the user clicks on the field, or a calendar icon next to the field, a modal calendar pops-up.
Once the user clicks on a date in the calendar window, the date is inserted into the date text field.

When a date is inserted into the field, I want to call a function to populate an array of dates. However, my OnChange event is not firing.

I have tried placing the code in the OnBlur event, but it executes too often (once when the calendar pops up, next when the user chooses a date and gets back to the field, ...).
And, if I place it with the OnClick event, it causes the event to fire before the date has been entered.

How can I get the OnChange event to execute? Or, if there's a better way, please let me know ;o)

Here's an abbreviated version of the code. Let me know if you need more details...

Thanks in advance!

Code:
function OpenCalWindow(WindowTitle,TargetField){
    //date currently in targetfield
    var dtValue = frmRequest.all(TargetField).value;
    //use server current date rather than client
    var today = frmRequest.hidToday.value;        

    window.open("Includefiles/Cal.asp?target="+TargetField+"&title="+WindowTitle+"&dtValue="+dtValue+"&today="+today,"Calendar","width=200,height=200,resizable=no,scrollbars=no,top=50,left=50");

}


function CalcDate(){
    //Build an array of dates...
    //and set another field on the form to the last date of the array.
}


<input type="text" 
value name="calStartDate" 
size="10" 
readonly
onclick="javascript:document.frmRequest.howOften(0).checked=true;javascript:theLastDay.style.display='none';javascript:OpenCalWindow('Date','calStartDate')"
onchange="javascript:CalcDate()"
style="cursor:hand;" 
title="Click to show calendar">
  #2 (permalink)  
Old August 22nd, 2003, 02:15 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I searched for hours trying to find a solution and couldn't find anything. Then, within 15 minutes of posting this, I found a solution.


http://www.experts-exchange.com/Web/..._20431888.html

Hope this helps someone else!


Similar Threads
Thread Thread Starter Forum Replies Last Post
SqlDependency OnChange Event ghari ASP.NET 2.0 Professional 1 July 30th, 2008 03:01 PM
onChange event mcinar HTML Code Clinic 3 May 24th, 2007 08:46 PM
onChange Event mcinar Javascript 11 May 11th, 2007 09:38 AM
how to use onchange event of dropdownlist check_007 ASP.NET 2.0 Professional 2 February 16th, 2007 02:57 AM
Event:OnChange catchrohith Classic ASP Basics 0 November 3rd, 2006 12:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.