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

Question

Question

Custom html text fields not getting captured

asked one day ago

The title says is all. I have a custom HTML script in my form where I have a diagram which lets users enter the fields into the diagram. I am able to enter the data into the diagram but after the submission that diagram made in custom html is empty. 

Here is the javascript code.

<script>
        // This script connects the HTML inputs to Laserfiche form fields
        // It needs to be modified based on your specific Laserfiche field names
        
        document.addEventListener('DOMContentLoaded', function() {
            // Get all input fields
            var inputs = document.querySelectorAll('.form-field');
            
            // Add event listeners to sync with parent form
            inputs.forEach(function(input) {
                input.addEventListener('change', function() {
                    // This is where we would integrate with Laserfiche form fields
                    // You'll need to modify this based on your specific Laserfiche setup
                    
                    // Example of how this integration might work:
                    try {
                        // Attempt to access parent Laserfiche form context
                        if (window.parent && window.parent.LFFormFields) {
                            window.parent.LFFormFields.setValue(input.name, input.value);
                        }
                    } catch (e) {
                        console.log('Integration with parent form failed:', e);
                    }
                });
            });
        });
    </script>


0 0

Replies

replied one day ago Show version history

Custom HTML items are static elements, not inputs fields, so no changes are captured.

If you want to store data entered into custom html inputs, you'll need to copy the values into form fields prior to submission, then reapply them to the custom html whenever the form loads.

1 0
replied one day ago

Sounds like an amazing idea, thanks. 

0 0
replied 8 hours ago

@████████

How do I copy the contents of the field from custom HTML over to a blank field in the form? 

0 0
replied 8 hours ago Show version history

The easiest way would probably be to add a hidden multiline field, then copy the raw HTML from the custom to that field.

I'm assuming you're using the classic designer since you have scripts and the modern designer scripts are sandboxed, and I don't know that it would be possible in the modern designer yet.

You'll need the field id for both the custom and the hidden field; just make sure your hidden field is Saving the content and not set to Ignore.

For example, to extract the raw html from a custom html with an id of 10, you could use either of the following:

// jQuery
let content = $('#Field10').html();

// vanilla JavaScript
let content = document.getElementById('Field10').innerHTML

Then, if your hidden field has an id of 20, you would use something like this to store the content to that field.

// jQuery
$('#Field20').val(content);

// vanilla JavaScript
document.getElementById('Field20').value = content;

Then on form load, you could reverse the process to apply the saved content back to your custom HTML.

// jQuery
let storedContent = $('#Field20').val();
$('#Field10').html(storedContent);

// vanilla JavaScript
let storedContent = document.getElementById('Field20').value;
document.getElementById('Field10').innerHTML = storedContent;

You can get the Ids by inspecting the page, or from the JavaScript/CSS tab; the "q#" values you see there correspond to the field ids, meaning "q10" would hold the field with the id "Field10"

0 0
replied 7 hours ago

I'm sorry, I am using the modern designer with sandboxed scripts. I did not know until a few hours ago I can do without having the script tags in the modern designer!!

Is there a solution in the modern designer for this? 

0 0
replied 7 hours ago

I know you can set the value of Custom HTML in the modern designer with the LFForm object, but I'm not sure if there's a way to copy it out.

The LFForm Object

0 0
replied 6 hours ago

Is there a way to store that value using custom HTML? 

I have a diagram drawn using custom HTML which takes in measurements for a product. They current way they do is through a pdf which works but going digital with that. The diagram is drawn and works but after submitting it gets empty and no values are copied. 

I dont know if saving would work in the mordern forms designer in on version 12. If there is any other way you could think of this can be done please let me know.  

0 0
replied 6 hours ago

At the moment, I don't know that this is possible. The Custom HTML element is meant for display, so it doesn't save changes like a field, and it isn't really designed for interactive elements.

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

Sign in to reply to this post.