Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnChange not working

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
Why doesn't this work? I'm trying to get the shipped date to equal the entered date plus 60 days when the entered date is changed.

<script language=&quot;JavaScript1.2&quot;>
function ChangeDate()
{
var NewDate = <output>#EnteredDate#</output>;
var ANewDate = EDate+60;
document.MyForm.ShippedDate.value = ANewDate;
}
</script>

<input type=&quot;text&quot; name=&quot;DateEntered&quot; value=&quot;<cfoutput>#EnteredDate#</cfoutput>&quot; onChange=&quot;ChangeDate();&quot;>
 
I don't think you need the <output></output> in the var declaration... I have not failed; I have merely found 100,000 different ways of not succeding...
 
A Question:

Where is EDate defined and coming from in your code?

function ChangeDate()
{
var NewDate = <output>#EnteredDate#</output>;
var ANewDate = EDate+60;
document.MyForm.ShippedDate.value = ANewDate;
}

Is: var NewDate = <output>#EnteredDate#</output>;
Really supposed to be: var EDate = <output>#EnteredDate#</output>;?

&quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
MrGreed,

The line should read:


var NewDate = <output>#EnteredDate#</output>;
var ANewDate = NewDate+60;

#EnteredDate# is the value of whatever date the user defines or sets.
 
You'll have to break down each date element (month,day, year) into numeric values before you can add anything to it. Otherwise, you're trying to do this: 11/01/02 + 60.

Your script doesn't have a clue what it's supposed to do. After you've done this, you'll have to convert everything back again. There's always a better way...
 
tviman,

Do you have an example of how I would do what you suggested?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top