I have a script that retrieves links from the Laserfiche repository.
These links are added to the form. $ ("# q6") .append (sURL);
The links are formed as follows: '<a href="' + sPrefix +'">' + sName + '</a>'
where sPrefix = http: //myserver/laserfiche/DocView.aspx? repo = XXXX & docid = '+ sId
When the form is submitted, the links are gone.
An idea of what's going on.
The code used
Question
Question
html links not saved
Answer
Hi Jim, Jason,
Indeed, there is no user input.
To work around the problem, I use rich text which I feed with links.
It works perfectly.
Attached is the code used.
Thanks for your help.
Replies
Hi Samir,
Here are two potential solutions:
- Try using $("#q6 .cf-custom").append instead, which should append it to the custom HTML in the field itself.
- Add in a custom element in the HTML field like <div id="custom_repo_link"></div> and then targeting that with $("#custom_repo_link").html .
Changes to custom HTML are not captured on a submitted form because they are not user inputs, but the secondary issue is that inputs are changed to static div elements upon submission.
As a result, if you're pulling your docId value from a field using something like $('#Field1').val() it isn't going to find anything because there is no longer an input from which to retrieve the value.
What you need is a dynamic process that can detect an input on a live form, and a static div element on the submitted form so it can determine whether to use .val() or .html() to retrieve your value.
Like so:
var value = $('#q1 :input').val() || $('#q1 div[type]:eq(0)').html() || '';
In this example, the code looks for a value in an input for #q1. If it gets a null result, it then checks if there's a static element (i.e., for a printable or saved form) for #q1. If that isn't found either it defaults to a blank value.
the :input and div[type] selectors are intentionally generic so they will work with different field types because the divs are given different field type attributes (input = text, email = email, etc.), but you should be able to use the id instead if you don't need to be as flexible.
You can get an idea of how this work by looking at a previously-submitted form in the instance history and inspecting the page elements.