You are viewing limited content. For full access, please sign in.

Question

Question

Fields Populated by Javascript do not show on submission

asked on October 17

I have a form that has multiple tables, each with 4 columns each.

The first 3 columns in each table are pre-filled via JavaScript. 

Originally I had the fields directly marked as "read-only", but upon submission, the fields were not showing. I read somewhere that by marking the fields directly as Read Only, JavaScript could not rewrite to the fields after Submission. The Read Only was removed, but the fields are now able to be modified. 

I read somewhere else to add to the JavaScript to use this format, $('.readonly input').attr("readonly","true");

However, the fields are not read-only. Unless I'm putting it in the wrong location. 
https://answers.laserfiche.com/questions/103690/javascript-calculation-not-stored-into-repository#103698

I attempted to contact MVI but was met with a $200 per hour to troubleshoot. Its not that dire of a case, but would like to fix it if possible. 

Any thoughts? 

1 0

Answer

SELECTED ANSWER
replied on October 17

I can not see why your fields would be editable. Try just a simple line that says

$('.read input').attr('readonly',true);

Then add the read class to a field and see if it works.

Better to do it this way so you have less code as well. We are just saying if a select field includes the class read, then make it read only.

1 0

Replies

replied on October 17 Show version history

Everything you stated sounds correct to me. If you use the read-only checkbox on the field properties, javascript that changes those field values will be lost in the archive image.

To work around this use the code just as you have it

Edit: I just noticed a code typo, the Boolean value of true had quotes around it making it a string.

Updated code

$('.readonly input').attr("readonly",true);

Did you remember to set the class name "readonly" on all the fields you want this to apply to?

Are they Single_Line fields? If they are other field types, you can not use "input", you might need "select" or "textarea"

2 0
replied on October 17

Sorry, that was just a copy from the referenced post. Attached is what my code (for one group) actually looks like. 

CodeSUPFORM.jpg
CodeSUPFORM.jpg (56.35 KB)
0 0
SELECTED ANSWER
replied on October 17

I can not see why your fields would be editable. Try just a simple line that says

$('.read input').attr('readonly',true);

Then add the read class to a field and see if it works.

Better to do it this way so you have less code as well. We are just saying if a select field includes the class read, then make it read only.

1 0
replied on October 20

That appeared to work! Thank you!

Apparently they had to have their own attribute. 

More rows, but it works like it should now! I already had 350+ rows, adding more wasn't an issue. 

 

UpdatedJS.png
UpdatedJS.png (27.78 KB)
0 0
replied on October 20

Oh you had too many quote characters in the original code. The way we reference multiple elements with jquery is with commas inside of the quotes, not outside of it. Always check the console for errors after saving new code.

Also you only need one line to designate a class that sets a field to readonly
 $('.read input').attr('readonly',true);

There are many redundant statements in your screenshot.

1 0
replied on October 22

So, the CSS class, I have every field named something different (as shown). 

I thought when creating this that those either needed to be Blank or different. (The the 4th field I don't have named, the Quantity field). 

 

If I am understanding what you are saying, is instead of having all these different "input" field names, they can all be named "read"? Being that its currently working, and the fact that there are over 150 fields that I'd have to correct (unless there is a way to quickly correct that, but I doubt it). 

1 0
replied on October 22

You can have multiple class names, separated by a space character.

The class names you have are great for referencing the exact value of that specific field in a function or changing that exact field but when your writing code to set a common attribute you should share a class name among all fields.

Now if you want to add a new read only field you can do so without going back to your code. You can also read and edit your code easier when you don't have redundant statements.

0 0
replied on October 17

Are you using the classic designer or modern?

0 0
replied on October 17

I believe its modern, but not sure how exactly to tell. 

Designerpage.png
Designerpage.png (55.78 KB)
0 0
replied on October 17

Nope, that's Classic.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.