Return to form and clear fields

I have a form, accesible via the web, that contains a number of editable fields and a NEXT button.

When the NEXT button is clicked I want to save the document and, if the user wishes to enter another set of data return them to the previous form with the fields cleared. Otherwise, the user should just continue to the next step:

var form = document.forms[0];

if (confirm(“Add another contact?”)){

form.submit();

}

else{

alert (‘Goto Next Step’);

}

I also have a $$Return field containing the following:

“”+@Char(13)+

“”+@Char(13)+

“<meta http-equiv="refresh" content="2;URL=javascript:resetFields();">”+@Char(13)+

“”+@Char(13)+

“<body bgcolor="#FFFFFF">”+@Char(13)+

“<div align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#31458C">One moment please… ”+@Char(13)+

“”+@Char(13)+

“”

On the JSHeader I have created a resetFields function:

function resetFields() {

window.history.go(-1);

form.ContactName.value=“”;

form.ContactTitle.value=“”;

form.ContactTelephone.value=“”;

form.ContactCell.value=“”;

form.ContactEmail.value=“”;

}

When the user enters the data and clicks the NEXT button, if they answer OK to the prompt, the message ‘One moment please…’ displays while the document is being saved, but I am not returning to the form (the form is displayed in the right portion of a two frame frameset). Instead I am returning to the last url - like I clicked the back button.

Am I trying to do the impossible? Any ideas or suggestions would be greatly appreciated. Thanks in advance.

Subject: return to form and clear fields

Your approach is going to have you editing the same document over and over. Try putting the url of the current form in $$Return; that will create a new document. Eg:

“[/” + @webdbname + “/formname?Openform]”

Subject: return to form and clear fields

maybe on the onLoad event you blank out the fields. This way every time the page is loaded the fields are blank.

Subject: return to form and clear fields

Hi,

I would do the following:

  1. Put a new editable Field on the Form, called “tmpField”; it must be on the HTML-Form but can be made invisble with type=“hidden”, use the HTML-Properties → Other to set this attribute.

  2. Your Save-Button has the following Javascript command

mySubmit();

  1. Your JS Header has the following function:

function mySubmit()

{

var form = document.forms[0];

if (confirm(“Add another contact?”))

form.tmpField.value = “next”;

form.submit();

}

  1. Your $$Return Field is Computed for Display and has the following code:

db := @ReplaceSubstring(@Subset(@DbName;-1);“\”;“/”);

@If(tmpField=“next”;“[/” + db + “/YOURFORMNAME?OpenForm]”;“[” + db +“ANYTHINGELSE]”)

Only drawback of this solution is, that you now will have an additional field called “tmpField”. You can get rid of it in a WebQuerySaveAgent.

HTH

Ruediger

Subject: RE: return to form and clear fields

I used the first response and it worked great.

Thanks to all!