The $_GET reference would require PHP. If you’re interested in doing that, you could simply change the file extension of your page to .php, and then in the Value property of the form element named order, you would put <?php echo $_GET['order']; ?>
. That will look awful in Freeway, but when viewed on a PHP server, it should just work.
If there isn’t a querystring with order=
in it, this will just do nothing (it will generate a warning, but those are usually not shown on screen in production servers, so you get away with it). If you wanted to be more professional about it, you could do something like this in the Page / HTML Markup / Before HTML section:
<?php
$order = '';
if(isset($_GET['order'])){
$order = $_GET['order'];
}
?>
…then, back in your order field, replace the previous raw echo of the $_GET global with simply <?php echo $order; ?>
.
For something as lightweight as this, though, you could also just use JavaScript, and not require anything special on the server. Again, if your field is named order, you would do something like this (this time in the Before /Body part of the Page / HTML Markup dialog):
<script>
var order = document.getElementById('order');
var params = new URLSearchParams(window.location.search);
order.value = params.get('order') || '';
</script>
Stepping through that one line at a time, the first line gets a reference to the field, relying on it having the ID set to order. If you name a field order, Freeway will do the correct thing here, but if this doesn’t work, that’s probably the problem. You can inspect the HTML in your browser and see if you find ` in there somewhere. If you don’t, then use the Inspector to ensure that the name of the field matches your expectations.
The second line gets an object reference to the querystring (formal name of ?foo=bar in a URL).
The third line sets the value of the field to either the order value from the querystring or an empty string if there is no order attribute in the URL.
Short and simple, for certain definitions of simple.
Walter
On Jan 14, 2021, at 2:24 PM, Richard Cacciato email@hidden wrote:
I want to create a form where data is automatically entered in a field from a url.
As an example, this url
domain.com/orderform.html?order=A123
would load the form orderform.html and automatically fill in the order field with the value A123.
Is there an easy way to do this?
I read here php - Auto-populate input form field from URL parameters - Stack Overflow that I can do this if I use “$_GET” but haven’t been able to figure out how to do it. Would love to know how.
Thanks in advance.
freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk
freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options