From 72baa18b863aafe7a8d79ae8690c185b4f56c5d6 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 24 Jan 2022 23:57:59 +0100 Subject: [PATCH] Prefill the form field though url parameters (#1021). --- assets/js/pages/booking.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assets/js/pages/booking.js b/assets/js/pages/booking.js index 3d60454f..654db3d8 100644 --- a/assets/js/pages/booking.js +++ b/assets/js/pages/booking.js @@ -220,9 +220,27 @@ App.Pages.Booking = (function () { .text(index + 1) ); } + + prefillFromQueryParam('#first-name', 'first_name'); + prefillFromQueryParam('#last-name', 'last_name'); + prefillFromQueryParam('#email', 'email'); + prefillFromQueryParam('#phone-number', 'phone'); + prefillFromQueryParam('#address', 'address'); + prefillFromQueryParam('#city', 'city'); + prefillFromQueryParam('#zip-code', 'zip'); } } + function prefillFromQueryParam(field, param) { + const $target = $(field); + + if (!$target.length) { + return; + } + + $target.val(App.Utils.Url.queryParam(param)); + } + /** * Remove empty columns and center elements if needed. */