sending URL to webform - Post ID 301452

User 1894811 Photo


Registered User
18 posts

I did change the variable Name to Fotonr when it gets the urlParams.

<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const Fotonr = urlParams.get('fotonr');
document.getElementById('fotonr').value = Fotonr; (Is this the webform document and hidden variable name?)
</script>
User 1894811 Photo


Registered User
18 posts

oh, and I get this error

webform.php?action=confirmation:36 Uncaught TypeError: Cannot set properties of null (setting 'value')
at webform.php?action=confirmation:36:41
User 1894811 Photo


Registered User
18 posts

I'm adding the whole webform.html here:

<!DOCTYPE HTML>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Start of the headers for CoffeeCup Web Form Builder -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"
/>
<script type="text/javascript" src="common/js/form_init.js" data-name=""
id="form_init_script">
</script>
<link rel="stylesheet" type="text/css" href="theme/craft_responsive/css/default.css?version=210"
id="theme" />
<!-- End of the headers for CoffeeCup Web Form Builder -->
<title>
webform
</title>

</head>

<body>

<!-- Start of the body content for CoffeeCup Web Form Builder -->
<style>#docContainer .fb_cond_applied{ display:none; }</style><noscript><style>#docContainer .fb_cond_applied{ display:inline-block; }</style></noscript><form class="fb-toplabel fb-100-item-column selected-object" id="docContainer"
action="../webform.php" enctype="multipart/form-data" method="POST" novalidate="novalidate"
data-form="manual_iframe">
<div class="fb-form-header" id="fb-form-header1">
<a class="fb-link-logo" id="fb-link-logo1" style="max-width: 104px;" target="_blank"><img title="Alternative text" class="fb-logo" id="fb-logo1" style="width: 100%; display: none;" alt="Alternative text" src="common/images/image_default.png"/></a>
</div>
<div class="section" id="section1">
<div class="column ui-sortable" id="column1">
<div id="fb_confirm_inline" style="display: none; min-height: 200px;">
</div>
<div id="fb_error_report" style="display: none;">
</div>
<div class="fb-item fb-100-item-column" id="item1">
<div class="fb-header fb-item-alignment-center">
<h2 style="font-size: 20px; display: inline;">
Schrijf je in voor onze nieuwsbrief
</h2>
</div>
</div>
<div class="fb-item fb-100-item-column" id="item4">
<div class="fb-grouplabel">
<label id="item4_label_0" style="display: inline;">Voornaam</label>
</div>
<div class="fb-input-box">
<input name="voornaam" id="item4_text_1" autofocus required type="text"
maxlength="100" placeholder="" autocomplete="on" data-hint="" />
</div>
</div>
<div class="fb-item fb-100-item-column" id="item5">
<div class="fb-grouplabel">
<label id="item5_label_0" style="display: inline;">Familienaam</label>
</div>
<div class="fb-input-box">
<input name="familienaam" id="item5_text_1" required type="text" maxlength="150"
placeholder="" autocomplete="on" data-hint="" />
</div>
</div>
<div class="fb-item fb-100-item-column" id="item6">
<div class="fb-grouplabel">
<label id="item6_label_0">Email</label>
</div>
<div class="fb-input-box">
<input name="email6" id="item6_email_1" required type="email" maxlength="254"
placeholder="you@domain.com" autocomplete="on" data-hint="" />
</div>
<div class="fb-grouplabel">
<label>Confirm</label>
</div>
<div class="fb-input-box">
<input name="email6_verification" id="item6_email_1_verification" type="email"
maxlength="254" placeholder="" autocomplete="on" data-hint="" />
</div>
</div>
</div>
</div>
<div class="fb-item-alignment-left fb-footer" id="fb-submit-button-div"
style="min-height: 1px;">
<input class="fb-button-special fb_cond_applied" id="fb-submit-button"
type="submit" data-regular="" value="Akkoord" />
</div>
<input name="fotonr" type="hidden" value="123212" />
<input name="fb_form_custom_html" type="hidden" />
<input name="fb_form_embedded" type="hidden" />
<input name="fb_js_enable" id="fb_js_enable" type="hidden" />
<input name="fb_url_embedded" id="fb_url_embedded" type="hidden" />
</form>
<!-- End of the body content for CoffeeCup Web Form Builder -->
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const Fotonr = urlParams.get('fotonr');
document.getElementById('fotonr').value = Fotonr;
</script>

</body>
</html>
User 187934 Photo


Senior Advisor
20,239 posts

Add an id to your hidden input.
<input id="fotonr" name="fotonr" type="hidden" value="123212" />


or you can use the input name in the script.
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const Fotonr = urlParams.get('fotonr');
document.querySelector("[name='fotonr']").value = Fotonr;
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1894811 Photo


Registered User
18 posts

Used this:

<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const Fotonr = urlParams.get('fotonr');
document.querySelector("[name='fotonr']").value = Fotonr;
</script>

Added this script part before end body tag

Still no new value of 000000

Then I set back the script to

<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const Fotonr = urlParams.get('fotonr');
document.getElementById('fotonr').value = Fotonr;
</script>

and used this line:
<input id="fotonr" name="fotonr" type="hidden" value="123212" />

and get this error in the confirmation page

"fotonr" is a required field and cannot be empty.

Christian
User 187934 Photo


Senior Advisor
20,239 posts

This is working for me. I see 111111 populated into the hidden input.
https://titeca.biz/test/webform.php?fotonr=111111
Try ctrl + f5.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1894811 Photo


Registered User
18 posts

Yep, now it does :|
Thank you for the help !!!
Christian

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.