Skip to main content
Inspiring
December 4, 2020
Answered

Make all form fields read only except generated template page

  • December 4, 2020
  • 1 reply
  • 1717 views

I have a two page form that once the user fills out and signs they click the submit button. The submit button has added to it a action mouseup javascript that makes all the fields read only and also generates a template page that is for admin use. So the idea is that once the form is submitted the person receiving the form on the other end will not be able to touch the fields on the first two pages but in the third page generated from the template.

 

I have two scripts running in the button plus submit form:

The first to generate the template page and hide two buttons:

var a = this.getTemplate ("AdminUse");
a.spawn();
this.getField("Submit").display = display.hidden;
this.getField("Reset").display = display.hidden;

 

The second to make all fields read only:
//getField("Text_Field").readonly = true;
for(var i=0;i<this.numFields;i++)
{
var fieldName = this.getNthFieldName(i);
if (fieldName == "FOR_ADMINISTRATION_USE_ONLY")
{
//console.println(i+":no:"+fieldName);... used in the debugger
}
else
{
//console.println(i+":"+fieldName);... used in the debugger
getField(fieldName).readonly = true;
}
}

 

The second script is making everything read only. Which is almost what I want but not quite. I need the field named "FOR_ADMINISTRATION_USE_ONLY" to remain fillable. Please help. What is wrong with the script? I'm struggling to find the correct solution to make that one field fillable.

This topic has been closed for replies.
Correct answer try67

In the submit button


Couple of issues:

1. You should not have split the code to two "Run a JavaScript" actions, since you can't control the order in which they are executed. Combine them to a single command, as well as the Submit Form action.

2. There's an error in your code. There's no field called "Reset", so this line fails:

this.getField("Reset").display = display.hidden;

Change it to:

this.getField("Reset Form").display = display.hidden;

3. You're spawning the Template using the default settings, which means the fields in it are renamed, so there's no field called "FOR_ADMINISTRATION_USE_ONLY" afterwards.

Change the spawn command to:

a.spawn({bRename: false});

1 reply

try67
Community Expert
Community Expert
December 5, 2020

The code seems fine... Are there any error messages when you run it? Are you sure you spelled the field name correctly?

Can you share the actual file with us?

Inspiring
December 7, 2020

I can share a modified version. How can I do that?

try67
Community Expert
Community Expert
December 7, 2020

You can attach it to the original message using the tiny paperclip icon at the bottom when you edit it, or upload it to a file-sharing website (like Dropbox, Google Drive, Adobe Cloud, etc.), generate a share link and then post it here.