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

Question

Question

html links not saved

asked on June 22, 2020

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

screenshot.png
screenshot.png (17.04 KB)
0 0

Answer

SELECTED ANSWER
replied on June 23, 2020

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.

0.Main.png
2..link.png
3.result.png
0.Main.png (87.49 KB)
2..link.png (8.96 KB)
3.result.png (12.47 KB)
0 0

Replies

replied on June 22, 2020

Hi Samir,

Here are two potential solutions:

  1. Try using $("#q6 .cf-custom").append instead, which should append it to the custom HTML in the field itself.
  2. 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 .
0 0
replied on June 22, 2020

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.

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

Sign in to reply to this post.