Adding current date + 3 months in a field

Z

ZedroS

Hi

I'm, you have guessed, a newB.

In my template, I've a field with the current date by default (the function
in English should be something like Today(), in French it's auj()). This
field can be changed after by the user.

I would like another field (next to the first one) to have the date today +
3 months. This field should be editable by the user.

Could you help me doing it ?

FYI, I just have Infopath of the Office 2003 SP1 pack, I don't have Visual
Studio and the like.

Thanks in advance

Kind regards
ZedroS
 
Z

ZedroS

Hi Reddy

Thanks for your answer.

In fact, my problem is more to manage to input this value as the default
value of my field. Indeed, I've the choice between :
- insert a field or a group
- insert a function -> only the default functions are offered, I don't
manage to insert a "developper's made" one

Do you have a clue ?

Thanks again

Best regards,
ZedroS
 
S

Sandeep

Hi ZedroS

Write this code in Infopath managed Jscript
expl:
Month starts to 0.
0 is jan.
So we can write here 5 means May.
("/my:myFields/my:field2") this is xpath of your field.


Past this code in OnLoad Function.

dtNextMonth = new Date();
dtNextMonth.setMonth(5);

XDocument.DOM.selectSingleNode("/my:myFields/my:field2").text = dtNextMonth;

I hope this will help U
 
S

Sandeep

Hi ZedroS

This code writen in JScript language.
Expl:
Month started to 0
0 is jan so here setMonth(5) means May.
("/my:myFields/my:field2") Here write your field Xpath.
.........
Past this code to OnLoad Function.

dtNextMonth = new Date();
dtNextMonth.setMonth(5);
XDocument.DOM.selectSingleNode("/my:myFields/my:field2").text = dtNextMonth;

I Hope this will Help U.
 
Z

ZedroS

Hi Sandeep

Sorry for the delay, I had other stuff to do (and I still do, but you know
;)).

First of all, thanks for your help. It's definitely helping me a lot.

However, I've run in another, the field where I would like to put a default
value is named toDatePresentation. The path in my DOM is
/test:news/test:toDatePresentation.

Furthermore, the field in question is in a section which is visible only if
a link is clicked on before.

So I've put your code but it does nothing on startup.

Thanks in advance

Cheers
ZedroS
 
Z

ZedroS

Hi Sandeep

Apparently the post I've made just before didn't make it.

So, once again ;) :

Thanks a lot ! Your help is most helpful to me !

However, the solution you offered doesn't work, at least, I think, for two
reasons :
- the name of the field where I want to put the default is different from
the data in my DOM. They are linked through a "data source".
- the field I want to interact with is situated in a optionnal section... I
don't know if it really matters but...

If you have any other clue I will happily take it !

Cheers
ZedroS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top