Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

reset form buttons

Contributor ,
Jul 25, 2023 Jul 25, 2023

Currently using a reset form button that resets entire form (several hundred fields spread across multiple pages). I would like to be able to optionally retain the data in certain fields while similtaneously resetting the form. Possible? These certain fields I want to retain also have same-named duplicate fields throughout the form (and spawned pages) whose data would also need to be optionally retained. Could a second button then be used to optionally reset only the certain fields whose data was retained? Thanks in advance for guidance!

TOPICS
How to , JavaScript
843
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 25, 2023 Jul 25, 2023

Use this and put fields names which you don't want to reset in 'notReset' variable:

var notReset = ["Field1","Field2","Field3"];
var resetFields = []; 
for (var i=0; i<this.numFields; i++){ 
var fname = this.getNthFieldName(i); 
if (notReset.indexOf(fname)!=-1) continue; 
resetFields.push(fname); } 
this.resetForm(resetFields);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2023 Jul 25, 2023

Use this and put fields names which you don't want to reset in 'notReset' variable:

var notReset = ["Field1","Field2","Field3"];
var resetFields = []; 
for (var i=0; i<this.numFields; i++){ 
var fname = this.getNthFieldName(i); 
if (notReset.indexOf(fname)!=-1) continue; 
resetFields.push(fname); } 
this.resetForm(resetFields);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 04, 2023 Aug 04, 2023

Thank you Nesa! Awesome!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 28, 2024 Jun 28, 2024

This is similiar to a problem I'm trying to solve for - but how do you allow for an option to be included with the reset, or release the information to be reset?

 

Name:

Address: (be able to lock/unlock for reset)

Phone #: (be able to lock/unlock for reset)

Shoe size:

Favorite pizza toppings:

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 28, 2024 Jun 28, 2024
LATEST

If you want to be able to select if specific fields should be reset or not, you could use 'response box' to load all specific fields names in question by default, then just remove names you don't want to reset, or with a series of alerts, or the more complex version custom dialog box with checkboxes to select which of the fields you wish to reset.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines