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

Question

Question

Capture parameter from URL to a hidden form field

asked on August 11, 2015

Hello all:

I need to populate a hidden form field using a parameter that is appended to a URL. I am sure I have done this in the past but for whatever reason, I can't figure out how to grab it from the URL as a variable.

Here is the example:

There is a "keycode" varibale appended to the URL of the web page where the form is embedded in an iFrame. The URL looks like this:

baseurl?keycode=MCE2234X

I have a field called KeyCode on the LF Form and have it hidden using css. I need to grab the keycode variable from the URL and enter it into the hidden field when the form gets submitted.

Can someone point me in the right direction? I thought this could be done without javascript but the only thing I can find by searching is javascript code.

 

Thanks in advance,

Eric

0 0

Answer

SELECTED ANSWER
replied on August 11, 2015

Try the suggestion from here to grab the parameter and pass/append it to the iframe src.

0 0

Replies

replied on August 11, 2015 Show version history
 
 

 You're on the right path.

 

That should populate the hidden field with the variable name "keycode". It should persist onto the next form if chosen to be displayed and populated with the value from the previous form.

 

Setup Field:

 

Verify value appears:

 

Now do it with it hidden with CSS:

Verify value persists:

 

 

Are you using an older IE browser by chance?

 

Cheers,

Carl

 
 
 
 
 
0 0
replied on August 11, 2015

I am using Firefox (latest version). Nothing I do will populate the URL parameter into the template field.

I have the variable set but I guess I am not sure what to put in field in the Save to Laserfiche step that would capture it and save it to the template field.

 

0 0
replied on August 11, 2015

The variable name is case sensitive. If your URL is using

keycode=MCE2234X

Then the variable that represents your field in the form also needs to be named "keycode" and that needs to carry over when you are configuring the "Save to Repository" task and setting the value from the form field into a template field. Note that the field label itself can be anything, as long as the variable name matches up with what you're using in the URL.

Here is my form design:

You'll notice the field label is "KeyCode" but I went and manually changed the variable name to "keycode"

I have this field hidden with CSS like

#q1 {display: none;}

Here's what the field configuration looks like in my "Save to Repository" task

I'm accessing the form with a URL like http://server/Forms/nXNQX?keycode=MCE2234X

And the final result is the document in the repository with the value obtained correctly

0 0
replied on August 11, 2015 Show version history

Thanks Carl and Alexander. This is exactly how I have it set up and I am being case sensitive. At this point I am going to break this out into a separate form and template rather than have it integrated into the existing form to rule out any overlapping issues.

The only other thing I am thinking is that that the form is placed in an iFrame on that page. Would that restrict me from getting to the URL parameter for any reason? The keycode parameter is in the URL of the main page, not the URL for the LF Form.

0 0
SELECTED ANSWER
replied on August 11, 2015

Try the suggestion from here to grab the parameter and pass/append it to the iframe src.

0 0
replied on August 13, 2015

Thank you Alexander... this worked for us. The issue was because the LF Form was in an iframe and not able to see the parameter variable in the page URL. Using the info in the link above allowed the parameter to be passed through to the iframe and I am able to write this varaible to the template field now.

Thanks again.

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

Sign in to reply to this post.