Function Problem

Results 1 to 2 of 2

Thread: Function Problem

  1. #1
    Join Date
    Dec 1969

    Default Function Problem

    I&#039;ve got 2 text boxes which contain dates, what I want to do is when one is updated the other field is also updated, I&#039;ve got the function an the textboxes below ...<BR><BR>Thanks in Advance ...<BR><BR>function ExpectedCompletion(){ <BR>if (confirm("Update Expected Completion?")) {<BR>document.frmProjDetails.txtExpCompletion.valu e=document.frmProjDetails.txtCompletionDate.value< BR>}<BR>}<BR><BR>&#060;input type="text" name="txtCompletionDate" size="10" readonly onClick="fPopCalendar(txtCompletionDate,txtComplet ionDate);return false" onchange="javascript:ExpectedCompletion()"&#062;<B R><BR>&#060;input type="text" name="txtExpCompletion" size="10" readonly onClick="fPopCalendar(txtActCompletion,txtActCompl etion);return false"&#062;

  2. #2
    Join Date
    Dec 1969

    Default But what is the problem???

    You give us code, say what you want to do, but don&#039;t describe any problem.<BR><BR>******<BR><BR>Having said all that...<BR><BR>I *think* I know the problem. You are apparently expecting that when the popup calendar changes that txtCompletionDate field that the onChange event will be triggered.<BR><BR>Nope. Doesn&#039;t happen. Only changes initiated by the browser *USER* will invoke onChange (indeed, that is true of almost all the onXXX events--no human, no event). Changes done via scripting don&#039;t count.<BR><BR>But the fix is easy:<BR><BR>&#060;input type="text" name="txtCompletionDate" size="10" readonly<BR> onClick="fPopCalendar(txtCompletionDate,txtComplet ionDate);ExpectedCompletion();return false" <BR> onchange="ExpectedCompletion()"&#062;<BR><BR>See? You just invoke the same function as onChange does from within the onClick, as a separate statement, just as the "return" is a separate statement.<BR><BR>You probably don&#039;t even need the onchange handler any more, as the field is "readonly" but it won&#039;t hurt to be there.<BR><BR>************<BR><BR>Next time, try *describing* the problem?<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts