How to make a date picker field empty?

V

Victor

Hi,

I have assinged a date into the date picker field at the beginning, then
i want to make the date pikcre field empty again programmatically, is it
possible? I have tried to put the date ficker field="" but it says must input
a date value. How? Is it possible to remove the date value after i have input
the date. I want to make the date picker field empty again by using program.
Is it possible?

Thanks in advanced!

Rgds,
Victor
 
S

S.Y.M. Wong-A-Ton

When you programmatically set a date field, you need to remove the nil
attribute on it before you can set its value. When you programmatically want
to empty a date field, you need to add the nil attribute back to the date
field.
 
V

Victor

Hi Wong,

Thanks for replying my query. Really appreciate that.

I still cannot get the answer. This is because how to programmatically
add the nil attribute back to the date field?

Is it by using addAttribute or setAttribute?

I tried both but the command after this method just won't execute. I don't
know why.

For example:

var
nIssDate=XDocument.DOM.selectSingleNode("//my:myFields/my:Items/my:Item/my:IssueDate");


if(!nIssDate.getAttribute("xsi:nil"))
{
XDocument.UI.Alert(nIssDate.text);
nIssDate.setAttribute("xsi:nil");
XDocument.UI.Alert(nIssDate.text);
nIssDate.text ="";
}

I can display the first XDocument.UI.Alert(nIssDate.text); but i
cannot display the second XDocument.UI.Alert(nIssDate.text);

What's wrong? Why after i put the nIssDate.setAttribute("xsi:nil"), the
message just won't display.

Your help is very much appreciated.

Regards,
Victor
 
S

sMcd

I'm having similar problems. I can get code to set/reset the xsi:nil attribute to work on new forms and/or the first instance of inputting a date, but it doesn't work when opening an existing form with a date already in the field. I believe this is true because you cannot set attributes on existing xml nodes with data (if you can, I sure can't figure out a way to do it!) -- you can play with attributes as you're creating the node (i.e. as you fill out the form or enter data in a field), but not once it has been created.

Which brings us back to your problem, Victor, and mine. How can you reset a date field to null after one has entered data and submitted/saved the form?

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
S

S.Y.M. Wong-A-Ton

Hey guys,

This topic has been discussed several times and there have been useful
threads/posts on the subject. Take a look at these two:

http://groups.google.com/group/micr...k=gst&q=xsi:nil&rnum=6&hl=en#32e614e9fd246461

http://groups.google.com/group/micr...k=gst&q=xsi:nil&rnum=8&hl=en#1225c0279e321790

Tip: If you find a post useful, rate it as such; posts usually disappear
(yearly cleanup or something similar) after a while if they have not been
rated. You can always find old posts back - as I did - via Google groups,
though, whether they have been rated or not.
 
S

S.Y.M. Wong-A-Ton

Victor, try createAttribute() or createNode() to create the attribute on the
date field (also see my reply to sMcd's post and the SetNil() jscript
function in the sample Absence Request form that comes with InfoPath).
Remember that you also have to give the attribute a value of "true".

Hope this helps.
 
V

Victor

Hi Wong,

Thank you so much for providing me such a useful help tips! I managed
to set the date picker field to be empty after i have input a date and save
it by using setNil() function from the Absence Request form sample. The
Absence Request Form sample really has a lot of functions to offer. I must go
through the code to find out more to be used for my future problems
encountered.

I have solved my friend's problem on making date picker field empty.
Now, i would like to solve my problem on how to count numbers of records when
there are two conditions applied which i have posted it under title "How to
count with two conditions?".

Please help me to take a look at the question to see if you can find out
a solution for me while i work it out myself too.

Thank you so much!


Regards,
Victor
 

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