i need a help with java script

amortization table using java script

Page 1 of 1

13 Replies - 2036 Views - Last Post: 02 July 2007 - 12:34 AM

#1 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

i need a help with java script

Post icon  Posted 06 June 2007 - 05:46 AM

i am using adobe designer which support java script, i am trying to do an amortization table, but unfortunitly it did not work with me, can you help with this, i am not a programmer i am just interested to learn the java script

thank you
Is This A Good Question/Topic? 0
  • +

Replies To: i need a help with java script

#2 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: i need a help with java script

Posted 06 June 2007 - 05:51 AM

Moved to Javascript forum.

Could you show us your Javascript so we can help?
Also, please specify what error(s) are you encountering, and what is the expected result.
Was This Post Helpful? 0
  • +
  • -

#3 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 07 June 2007 - 03:56 AM

View Post1lacca, on 6 Jun, 2007 - 05:51 AM, said:

Moved to Javascript forum.

Could you show us your Javascript so we can help?
Also, please specify what error(s) are you encountering, and what is the expected result.


First what i am trying to do is a date series based on a certain date, like those used in the amortization table, actually its an amortization table, but my problem is the generation of dates some how i did this script but the result was when i reach Dec (12) the next date generated is the month 13 it does not go for the next month wihch should be jan. (1) next year, i am using adobe designer to desinge a form.

this is the script:


var d = new Date(TextField1.formattedValue);
var mmonth = d.getMonth() + 1 ;
mmonth++;
TextField2.formattedValue = mmonth;
var mday = d.getDate();
var myear = d.getFullYear()
TextField2.formattedValue = mday + "/" + mmonth + "/" + myear ; //(curr_date + "-" + curr_month + "-" + curr_year);

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#4 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: i need a help with java script

Posted 08 June 2007 - 05:11 PM

You've incremented your month value by 1 (mmonth++) right after adding 1 to compensate for the array offset (var mmonth = d.getMonth() + 1). This would cause mmonth to display a value of 13 for December. Remove "mmonth++" and it should return the correct values.

2
Was This Post Helpful? 0
  • +
  • -

#5 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 08 June 2007 - 11:37 PM

View PostDilutedImage, on 8 Jun, 2007 - 05:11 PM, said:

You've incremented your month value by 1 (mmonth++) right after adding 1 to compensate for the array offset (var mmonth = d.getMonth() + 1). This would cause mmonth to display a value of 13 for December. Remove "mmonth++" and it should return the correct values.

2


Thank you very much for your replu, unfortunitly it did not wotk, when i remove "mmonth++", the value i got id the same i entered.
Was This Post Helpful? 0
  • +
  • -

#6 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: i need a help with java script

Posted 09 June 2007 - 02:13 PM

I'm sorry, I misread what you were wanting to do. Do leave that "mmonth ++;" in place. Then, on the next line, insert this:
 if(mmonth >= 13) { mmonth = 1 };

Was This Post Helpful? 0
  • +
  • -

#7 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 10 June 2007 - 11:52 PM

View PostDilutedImage, on 9 Jun, 2007 - 02:13 PM, said:

I'm sorry, I misread what you were wanting to do. Do leave that "mmonth ++;" in place. Then, on the next line, insert this:
 if(mmonth >= 13) { mmonth = 1 };



Thanks alot, but it did not work too, this is what i did

----- form1.#subform[0].DateTimeField2::calculate - (Javascript, client) ---------------------------

var d = new Date(DateTimeField1.formattedValue);
var mmonth = d.getMonth() + 1 ;
mmonth++;
if(mmonth >= 13) { mmonth = 1 } {myear + 1};
DateTimeField2.formattedValue = mmonth;
var mday = d.getDate();
var myear = d.getFullYear()
DateTimeField2.formattedValue = mday + "/" + mmonth + "/" + myear ; //(curr_date + "-" + curr_month + "-" + curr_year);
Was This Post Helpful? 0
  • +
  • -

#8 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: i need a help with java script

Posted 11 June 2007 - 05:05 AM

It didn't work because you've implemented the "myear + 1" improperly. This is the correct way to do that:

if(mmonth >= 13) { mmonth = 1; myear + 1};

The curly braces enclose the code that is to be executed if the IF condition is met, and the semicolons separate each line of code.
Was This Post Helpful? 0
  • +
  • -

#9 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 13 June 2007 - 07:42 AM

View PostDilutedImage, on 11 Jun, 2007 - 05:05 AM, said:

It didn't work because you've implemented the "myear + 1" improperly. This is the correct way to do that:

if(mmonth >= 13) { mmonth = 1; myear + 1};

The curly braces enclose the code that is to be executed if the IF condition is met, and the semicolons separate each line of code.


thank you very much for the clarification, i will try it and let you know
Was This Post Helpful? 0
  • +
  • -

#10 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 26 June 2007 - 03:58 AM

View Posthammoudeh, on 13 Jun, 2007 - 07:42 AM, said:

View PostDilutedImage, on 11 Jun, 2007 - 05:05 AM, said:

It didn't work because you've implemented the "myear + 1" improperly. This is the correct way to do that:

if(mmonth >= 13) { mmonth = 1; myear + 1};

The curly braces enclose the code that is to be executed if the IF condition is met, and the semicolons separate each line of code.


thank you very much for the clarification, i will try it and let you know


the main problem with me now is the date format, how can i do the format day,month,year, what happend with me that : i do input a date in a cell which the script will read from, the script read the format as month, day , year and produce it in the next cell day, month, year.
Was This Post Helpful? 0
  • +
  • -

#11 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: i need a help with java script

Posted 26 June 2007 - 05:53 PM

I'm confused as what you're wanting to do. Please provide a sample of the result you'd like produced. For example: "An input of 10/05/07 creates an output of 11/05/07".
Was This Post Helpful? 0
  • +
  • -

#12 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 27 June 2007 - 05:23 AM

View PostDilutedImage, on 26 Jun, 2007 - 05:53 PM, said:

I'm confused as what you're wanting to do. Please provide a sample of the result you'd like produced. For example: "An input of 10/05/07 creates an output of 11/05/07".


I am sorry for not being clear,

if the input is "6/27/2007 " the result is "27/7/2007", what i am asking for is how to do the script to read it as "27/6/2007" to produce "27/7/2007"

this is the script one more time...


var d = new Date(TextField1.formattedValue);
 
var mmonth  = d.getMonth() + 1;
var mday = d.getDate();
var myear = d.getFullYear()
 
mmonth++;
 
if(mmonth >= 13)
{ 
myear++;
mmonth = 1;
};
 
TextField2.formattedValue =  mmonth;
 

TextField2.formattedValue =  mday  + "/" + mmonth + "/" + myear; //(curr_date + "-" + curr_month + "-" + curr_year);


[mod edit] And here am I again adding code tags for you. The code tags are there for a reason, use them.

This post has been edited by hotsnoj: 27 June 2007 - 07:17 AM

Was This Post Helpful? 0
  • +
  • -

#13 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: i need a help with java script

Posted 27 June 2007 - 12:14 PM

So, in the input box, you're looking to swap the placement of the month and day values?
Was This Post Helpful? 0
  • +
  • -

#14 hammoudeh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-June 07

Re: i need a help with java script

Posted 02 July 2007 - 12:34 AM

View PostDilutedImage, on 27 Jun, 2007 - 12:14 PM, said:

So, in the input box, you're looking to swap the placement of the month and day values?


exactly that what i am looking for.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1