Print Page | Close Window

resetform after send

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=114
Printed Date: 18 Sep 2019 at 12:41pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: resetform after send
Posted By: ljsmith
Subject: resetform after send
Date Posted: 18 Nov 2011 at 5:51pm
I'm trying to figure out a way to reset a form after an email is sent, without making the user manually click on the clear/reset button.
 
The form is extended, but we don't want the users to save the data locally. Yes, I realize the sent folder will have a copy, but the worry is having data persist causing input errors when the user reuses the form and doesn't clear all the data out before reusing.
 
I've tried creating two functions that basically check for a hidden field value which is blank for sending and once sent, it reads "Sent" (also may read "Error" if it hasn't passed validation....)
 
So basically I have one function to handle the send and a second to handle the reset. I did this because combining the code was clearing the form before the send. I split it hoping for a different reaction, since basically it would need to finish one function before beginning the next, but I'm getting the same result.
 
orignal send button code looks something like this:
 
function sendForm()
    var pH = this.getField("fieldName4").value
 
    Mandatory("fieldName1","fieldName2","fieldName2","fieldName3");
 
   if(pH == "") {    
     var esubject = "Test Send";
     var mBoxTo = email@domain.com;
     this.mailDoc(true, mBoxTo, esubject);
     }
   this.resetform()    
}
 
So, am I trying to do the impossible or does anyone have suggestions on how to get around this conundrum?
Confused


-------------
--
L. Smith
laura@ljsmith.ca
Common sense isn't.



Replies:
Posted By: gkaiseril
Date Posted: 21 Nov 2011 at 2:55pm
You need to place the "this.resetform()" within the block of code for the "if" statement.
 
I am not familiar with the "Mandatory" function. Can you explain what it does.
 
I would have written a function that return a logical true of false value and use the statement that calls that function to control the action of the 'if' statement.
 
 


Posted By: ljsmith
Date Posted: 21 Nov 2011 at 3:01pm
The Mandatory function goes through the form and looks for checkboxes, radio buttons, text fields and combo/listboxes that are marked as required, but are empty or not selected (in the case of checkboxes and radio buttons, it would look for a series of either one with the same name, with no selection).
 
The pH value is what holds the check. If everything passes the mandatory field check, it will be empty. Otherwise, it holds a value of "Error". It's a visible but won't print field, I've set in white text. When we're testing, to make sure we've got everything working as necessary, we change the text colour to black so it's visible to us and we can verify the results. Otherwise, set in white text, it doesn't print out.
 
The problem I've been encountering is if I put the this.resetform() earlier in the code - it's wiping the fields before it's sent, and we want the data sent but don't want the form retained with data in it locally.
 
 


-------------
--
L. Smith
laura@ljsmith.ca
Common sense isn't.


Posted By: aandi
Date Posted: 21 Nov 2011 at 3:43pm
But the code as written calls resetForm even if the tests in Mandatory() fail...


Posted By: ljsmith
Date Posted: 21 Nov 2011 at 4:22pm
It was one variant of the code, trying different placements, trying to get the form to blank after send.
 
I have gotten it to work, moving it to before the preceding "}" and it works.
 
There must have been a secondary trigger that was blanking the form before send that I'd cleared out in the mock code when I posted it here.
 
Been too long away from JS, and buried in VBA. While the logic while similar, definitely isn't the same. Wink


-------------
--
L. Smith
laura@ljsmith.ca
Common sense isn't.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net