Is it possible to turn user input on a String field into a clickable link that displays on the form?

Shant Cancik
Tera Contributor

This is a bit of a strange requirement but I need to figure out a way to take a string that a user enters into a string field and then turn it into a clickable link for them.

My initial thought process for how I'd do this is to create two fields : 

1) Value field (String)

2) Created Link field (String and set to read only)

 

I then use an onChange client script to take the string entered in the value field and add it to the end of the URL given to me from my client (I'll use "www.website.com/" as an example for now).

So... if the user entered "test" then my ceated link field would display "www.website.com/test" .

 

This will work but is there any way to do this and also have the link clickable? Maybe my initial idea for how to do this isn't ideal?

 

Thanks for any input!

1 ACCEPTED SOLUTION

shawna
Tera Guru

Change Created Link Field from text field to html field rather. In client script, when creating the link, create links with <a href="url"></a>, try something like this:

for (i=0; i<arr.length; i++) {


var url = "<a href="https://www.website.com/" + arr[i] + "></a> ";

g_form.setValue('u_created_link_field", url);

}

 

View solution in original post

8 REPLIES 8

Rahul Shandily3
Giga Guru

Kepp two sets of field. String and URL, Keep the URL field hidden until user enters the data in the string. Once the data is entered and saved/processed, display the URL field with the updated url text and hide the string field.

 

Hope this works.

 

Best Regards,

Rahul

Please mark this as correct/helpful if it resolved your query.

Hey Rahul, thanks so much for the info! Unfortunately it turns out that I have an additional requirement to what I need  to do here. This needs to be applicable in the event that multiple values are entered.

 

Currently to do this I have the Value and Created Link fields set up as two large string fields and I have instructions to the user to enter multiple values separated by comments.

 

Once the user enters the values an onChange client script logic runs to populate the 2nd field with URLs:

 

var url = "";
var str = g_form.getValue('u_value_field');
var arr = str.split(", ");
for (i=0; i<arr.length; i++) {
url = url + "<https://www.website.com/" + arr[i] + " ";


g_form.setValue('u_created_link_field", url);
 

 

Since this 2nd field is a string, they are not clickable. I believe what you suggested should work but I'm not sure how I'd make it work with multiple inputs. Would you have any thoughts about that?

Hey Shant,

 

Can you give the data as inputs and what will be the respective outputs. I can probably feed you with the script then.

 

Best Regards,

Rahul

 

Hi Rahul,

 

Thanks so much for your help!  So here is an example of what a user could enter into the first field:

11111, 22222, 33333, 44444 5555

 

Once they enter that I'd need clickable URL links to generate on the form. They'd look like this:

www.website.com/11111

www.website.com/22222

www.website.com/33333

www.website.com/44444

www.website.com/55555

 

Like I said, I have this working using 2 large string fields and an onChange script but none of the links are clickable. Thanks again fro the help!