Reset form on submit using jscript? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Reset form on submit using jscript?

Last post 09-12-2010 07:59 PM by ZhenYuan. 30 replies.
Page 2 of 3 (31 items) < Previous 1 2 3 Next >
Sort Posts: Previous Next
  • 08-11-2010 06:48 PM In reply to

    Re: Reset form on submit using jscript?

     I got it, you have to create a reference of Form_Container on Form_Clone.

    To do that, right click on Form_Container click reference, choose Form_Clone and click ok.

  • 08-11-2010 07:13 PM In reply to

    Re: Reset form on submit using jscript?

    Thank you so much! It works now!

     Thanks again!

  • 08-11-2010 08:08 PM In reply to

    Re: Reset form on submit using jscript?

    You're welcome !
  • 08-12-2010 03:30 AM In reply to

    Reset form on submit using Visual Basic coding

    Hi,

     I'm stuck again :(

    My form has mandatory fields and since I cloned the container at the beginning, the clone has the empty mandatory fields! And of course, the form now fails to get submitted as the required fields are empty...

    Is there a way to remove the clone using my submit button? I'm using DBXL's web service submit and thus my submit button has no code to alter. If I choose to alter the submit code, they give me a clean slate to code my submit and I have no idea how to code all those web service data connections, etc...

    Attached is my sample form again with a mandatory field. Preview it, fill up the mandatory field and try to submit. You will see what I mean...

    Thanks!

  • 08-12-2010 05:05 AM In reply to

    Re: Reset form on submit using Visual Basic coding

     Hi, an easy way is to put some default value on your reference mandatory field. And modify your reset bouton to empty it when it clicked: add this code at the end of your function:

    Me.CreateNavigator().SelectSingleNode("/my:myFields/my:Form_Container/my:Field1", Me.NamespaceManager).SetValue("")

  • 08-12-2010 06:19 PM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi,

     I suppose your "my:Field1" refers to all my individual mandatory fields? Meaning if I have 10 such fields, I must individually setvalue to "" right? I tried for one field and it works. Just wondering if I am doing it right or doing it the long way.

     Thanks again for your greatly appreciated help!

  • 08-13-2010 09:04 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi Zhen Yuan, if you have 10 mandatory fields it could be easier if you replace your mandatory field by data validation you just have your error message on the submit for your form_container node.

    If you can't do that, you can create manually an xml node like your  form_container and use it like your clone and remove the reference.

  • 08-16-2010 12:31 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi,

    Your first suggestion won't be good for my users. They would want to know exactly where the error is, ie, which field they keyed incorrectly. lf I were to put the error on submit, they would have to scroll and find the field. I'll get stick for this :(

    For your second suggestion, how do you remove a reference? Are you suggesting: create 2 clones of form_container, one as the default form while the other has dummy data in the mandatory fields. On Reset, the default form clone refreshes the form while the dummy clone clones the default form clone (so that now there are no empty mandatory fields in the default form clone)?

    Anyway, I used your replace field code to replace the refreshed form and it works fine. I have like 12 such lines of replacements but it suits my purpose just fine. Especially when this allows me to continuously reset the form.

    Now for emailing the form as a template... my buttons went missing! Shall look for a related thread or post a new one soon!

    Thanks!

  • 08-16-2010 08:43 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi Zhen Yuan, if you use data validation instead of mandatory field you get an red mark on your textbox, the user can know  exactly where the error is. You configure it on the text box not on the field, that why you won't have an issue on the submit for your reference field.

    But If you prefer to replace your 12 fields it works too.

  • 09-09-2010 08:59 AM In reply to

    Re: Reset form on submit using Visual Basic coding

     

    Hi Potemkine, Now I need to go one better. Remember previously I wanted to reset all field values from my form via a button? That was settled. Now I want to reset even the secondary data connections. Can I use some code (Visual Basic) to clear my specific data connections?

    My form has some search function whicn populates a listbox with its results. I noticed that resetting the form clears all the form fields but not the listbox because it is tied to a data connection that is holding data from the previous search.

     Hope you have a solution?

     

    Thanks!

  • 09-10-2010 08:50 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi ZhenYuan,

    try this:

    XPathNavigator test = Me.DataSources["DATACONNECTION"].CreateNavigator();
    test.SelectSingleNode("dfs:myFields",Me.NamespaceManager).DeleteSelf();

     

     

     

     

  • 09-11-2010 03:38 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi,

    This worked fine for the first time only. After which, if I try to reset again, I get a System.NullReferenceException error. I tried doing checks for nulls using:

    XPathNavigator test = Me.DataSources["DATACONNECTION"].CreateNavigator();

    If test.SelectSingleNode("dfs:myFields", Me.NamespaceManager).Value Is DBNull.Value Then

    else

    test.SelectSingleNode("dfs:myFields", Me.NamespaceManager).DeleteSelf()

    End If

    In any case, after the first deleteself, the data connection is unusable from then on! When I try to perform my query using the data connection, an error pops out:

    Some rules were not applied. The parameter is incorrect.

     

    Any clues to help? Thanks!

     

     

  • 09-11-2010 11:15 AM In reply to

    Re: Reset form on submit using Visual Basic coding

     Hi, you have to query your data connection with rules or code to make them re-usable. You can make a try catch for your null exection

    Me.DataSources["DATACONNECTION"].QueryConnection.Execute();

  • 09-12-2010 12:13 AM In reply to

    Re: Reset form on submit using Visual Basic coding

    Hi Potemkine,

    You mean place the try catch code in the reset button code or in the Query button code (the query button which did not work after the reset).

    My form has a rest button as well as several Query buttons in the form where users can click to query our database based on certain inputs in the form. My aim is to have a form where users can reset the form after a wrong filling and the data sources are cleared for reuse.

    Right now, if I click the reset button twice, a null error occurs. The separate issue is that after using the code to clear data source, my query button fails as well. It fails to perform its original task of connecting to the data source for data.

  • 09-12-2010 05:53 AM In reply to

    Re: Reset form on submit using Visual Basic coding

     Hi, you can place your try catch just on the line to delete your secondary data connection, you can also make an if statemment like

    if (test.innerxml !="")

    .

    .

    .For your other issue, you have to Re query your dataconnection because you just delete it.You can set a rules or codes (the one on my last post)if you have an issue with that when you try it, please use a separate button with just a rule that query your dataconnection.

Page 2 of 3 (31 items) < Previous 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.