-
OntrexAsked on January 12, 2018 at 8:27 AM
I would want to populate a parameter in my form from a variable I calculated in a js, i.e. like this
<script type="text/javascript">
var MyParam=function().param('data');
</script>resulting in MyParam containing a data string.
For a lightbox form I found that I could populate my form like this:
<script src ="https://form.jotformeu.com/static/feedback2.js" type="text/javascript">
<script type="text/javascript">
var JFL_80112205327341 = new JotformFeedback({
formId: '80112205327341',
base: 'https://form.jotformeu.com/',
windowTitle: 'Parameter Test',
iframeParameters: {
'parameter': MyParam
},
background: '#FFA500',
fontColor: '#FFFFFF',
type: 'false',
height: 500,
width: 700,
openOnLoad: false
});
</script>
<a class="btn lightbox-80112205327341" style="margin-top: 16px">
Parameter in Lightbox Form
</a>However, I cannot use a lightbox, but need to use a regular embedded form, which I would normally call in html with
<script type="text/javascript" src="https://form.jotformeu.com/jsform/80112205327341?parameter=12345"></script>
But instead of the static 12345 I would need to have the dynamic MyParam
Any ideas?
Thank you
-
aubreybourkeReplied on January 12, 2018 at 10:09 AM
Yes its possible to prepopulate a form with a URL parameter.
Please try using this tool. It makes it very easy to generate the URL you require.
https://prepopulate.jotform.io/
-
OntrexReplied on January 12, 2018 at 10:26 AM
Thank you, but that's not answering the question, I'm afraid.
I do know how to populate fields from an URL with _static_ parameters. However, I would need to do so using a _variable_ that I dynamically create in a javascript first.
-
aubreybourkeReplied on January 12, 2018 at 11:11 AM
I created a demo that uses a HTML form. On submission it reloads the page, passing the parameter to the form.
https://aubreythankyou.000webhostapp.com/reload.html
Copy and paste the code into an empty text file.
And save it as "reload.html"
The code looks like this:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript" src="https://form.jotform.com/jsform/80114452536955"></script>
<form action="reload.html?data">
First name:<br>
<input type="text" name="data" value="Mickey">
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
I guess you could create a JavaScript version of this idea?