Greetings,
I am looking for a way to create a custom button that when pressed will clear or reset all (and/or selected) fields in the form.
I found a snippet of JavaScript that I hoped would work but it is not clearing the fields.
I've created a simple form with 3 fields; a single line text, a multi line text and a person/group field Named NameOfBox1, NameOfBox2, NameOfBox3 respectively.
The code I am trying to use on client click is;
NWF$(document).ready(function(){
var obj = NWF$("#" +Choices);
obj.change(function(){
NWF$("#" + NameOfBox1).val('');
NWF$("#" + NameOfBox2).val('');
NWF$("#" + NameOfBox3).val('');
} );
} );
Any help will be greatly appreciated.
Solved! Go to Solution.
You can add a button on the form and configure it to be a Javascript button (Button action field). In the Advanced section of the button's settings, you can populate the Client click field with the following :
resetForm();
Then you can add the following javascript function in your form (in a javascript file referenced in your Nintex form or in the Custom Javascript section in the settings of the form) :
function resetForm() {
// Reset a single line field
NWF$("#" + NameOfBox1).val('');
// Reset a plain text multiline text field
NWF$("#" + NameOfBox2).val('');
// Reset a people picker
var peoplePickerControl = new NF.PeoplePickerApi("#" + NameOfBox3);
peoplePickerControl.clear();
}
Do you have a rich text or plain text multiline control ?
Hope this helps
Can this be done on the SQL Request? Essentially I have another SQL request populating one field (Customer) and they want to return back information from that SQL database with the leads for that customer
Do you want to re-execute the SQL request after the form has been loaded ?
Yes please
Unfortunately it is not possible but I think that this feature is on the roadmap
I am trying to clear the custom signature field only with a click of a button on desktop version of forms, which is a multiple line plain text field. When i use the code you provided me it clears the whole form. I am only using the portion of the code you have provided:
function resetForm() {
NWF$("#" + NameOfBox2).val('');}
That's really Strange that with only this function it clears all the form.
Have you populated the Store Client ID in a Javascript variable for each control in your form? If so, have you populated a different name for each control?
I have stored client id only for the button to clear the signature field. The multiple line plain text signature box already has client id stored on it.
Well, in this case it cannot be due to the following lines of code :
function resetForm() {
NWF$("#" + NameOfBox2).val('');
}
Can you try to change the name of the function to myCustomResetFormFunction?