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

Question

Question

Use a field value from a DB lookup in a URL in the same form.

asked on August 9, 2020

Hi All

I have a field "Company Name" that is populated from db Lookup, i then want to use this field value in a URL populating the "Company Name" in URL in a Custom HTML field.

Ive read that you cant use the value without submitting as the value hasn't been entered in the forms database and that JavaScript is needed to update the value.

<p><font size="4">Click this link to access the Induction Page</font></p><a href="https://test.co.nz/Forms/Induction?Type_of_Induction=20&amp;Company={/dataset/Company_Name}" target="_blank" "=""><font size="4">Click Here</font></a>

I'm using the "dataset/company_name" in the URL but what JavaScript do i need to update the "Company_Name" so its appears in URL ?

Appreciate any advice given

0 0

Answer

SELECTED ANSWER
replied on August 10, 2020 Show version history

Change the Custom HTML field to the following. This will make it empty, but the JavaScript will fill it when the Company Name is changed.

<font size="4"><p id="InductionLinkIntro">&nbsp;</p>
<p id="InductionLink">&nbsp;</p></font>

Add the following JavaScript code:

$( document ).ready(function() {
    
  // Runs when the Company Name changes
  $( "#Field2" ).change(function() {
    
    // Adds the introductory text
    $("#InductionLinkIntro").html("Click this link to access the Induction Page");
    
    // Adds the link
    $("#InductionLink").html("<a href=\"https://test.co.nz/Forms/Induction?Type_of_Induction=20&amp;Company="+ $( "#Field2" ).val() +"\" target=\"_blank\">Click Here</a>");
});
});

In my form, Field2 was the field where the company name is. Change it as needed to match your form.

2 0

Replies

replied on August 10, 2020

That works perfectly !! thanks Stephen

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

Sign in to reply to this post.