Postcode direct laden na invoer

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

10/05/2021 13:43:14
Quote Anchor link
Beste leden,

Op dit moment heb ik een textbox area waar ik een postcode invul (bijvoorbeeld 7607).

else if (text_form.text_name.value == "7607")
document.getElementById("demo").innerHTML = "Postcode 7607 ";

Nu krijg ik de tekst "Postcode 7607".

Graag zou ik de button van hieronder in het javascript Postcode 7607 willen plaatsen.
Maar wanneer je de postcode invoert dat de pagina direct wordt geladen, niet dat je nog op de button moet klikken.

<span class="btn btn-primary btn-block" data-glf-cuid="e81ccf63-7066-46b4-a684-4a69b2383f42" data-glf-ruid="2d28297f-2608-4787-9456-023ff0e90368" > Postcode 7607 </span>
<script src="https://www.fbgcdn.com/embedder/js/ewm2.js" defer async ></script>

Met vriendelijke groet,

Levy

https://www.fbgcdn.com/embedder/js/ewm2.js

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
! function a(b, c, d) {
    function e(g, h) {
        if (!c[g]) {
            if (!b[g]) {
                var i = "function" == typeof require && require;
                if (!h && i) return i(g, !0);
                if (f) return f(g, !0);
                var j = new Error("Cannot find module '" + g + "'");
                throw j.code = "MODULE_NOT_FOUND", j
            }
            var k = c[g] = {
                exports: {}
            };
            b[g][0].call(k.exports, function (a) {
                var c = b[g][1][a];
                return e(c || a)
            }, k, k.exports, a, b, c, d)
        }
        return c[g].exports
    }
    for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
    return e
}({
    1: [function (a, b, c) {
        function d(a) {
            var b;
            "string" == typeof a.data && (a.data.startsWith("removeWidget") ? (b = document.getElementById("gfOrderFrm"), b && b.parentNode.removeChild(b), document.getElementsByTagName("body")[0].style.overflow = "auto", M && M()) : a.data.startsWith("removeWidgetTab") && F ? (F && F.close && F.close(), M && M()) : a.data.startsWith("removeButtonAnalyticsFrame") && (b = document.getElementById("gfButtonAnalyticsFrame")) && b.parentNode.removeChild(b))
        }

        function e(a, b) {
            var c;
            !G && b.hasChildNodes() && b.childNodes.length > 0 && (G = !0, document.createStyleSheet ? document.createStyleSheet(D + "embedder/css/order-online.css") : (c = document.createElement("link"), c.setAttribute("rel", "stylesheet"), c.setAttribute("href", D + "embedder/css/order-online.css"), c.setAttribute("type", "text/css"), c.setAttribute("media", "screen"), a.appendChild(c)))
        }

        function f(a) {
            var b, c, d, f, h, j, k, l = document.getElementsByTagName("head")[0],
                m = document.getElementsByTagName("body")[0];
            for ("object" == typeof a && a || (d = {}, d.url = arguments[0], d.elementIds = arguments[1], d.companyUID = arguments[2], d.restaurantId = arguments[3], d.sliderMode = arguments[4], d.adminMode = arguments[5], d.noDevice = arguments[6], a = d), b = a.url, c = a.elementIds, e(l, m), f = g(a), a.restaurantUID && !H && (s(), u(w(f)), H = !0), t(a.restaurantUID), M = !!a.closeHandler && a.closeHandler, h = 0; h < c.length; h++) j = c[h], (k = document.getElementById(j)) && y(k, "click", function () {
                i(b, f, a.forceMode, a.isCustomUrl)
            })
        }

        function g(a) {
            var b = {};
            return a.referrerTracker && (b.ref_tracker = a.referrerTracker), a.reservation && (b.reservation = a.reservation), a.restaurantId && (b.restaurant_id = a.restaurantId), a.companyUID && (b.company_uid = a.companyUID), a.restaurantUID && (b.restaurant_uid = a.restaurantUID), a.adminMode && (b.admin_mode = !0), a.promotionTest && (b.promotion_test = !0), a.analytics && a.analytics.forEach(function (a) {
                b[a.key] = a.value
            }), b
        }

        function h(a) {
            var b = a.url,
                c = g(a);
            M = !!a.closeHandler && a.closeHandler, i(b, c, a.forceMode, a.isCustomUrl)
        }

        function i(a, b, c, d) {
            if (window.snowplow_legacy && -1 === a.indexOf(document.location.hostname)) {
                var e = new RegExp("_sp_id\\.[a-f0-9]+=([^;]+);?"),
                    f = document.cookie.match(e);
                f && f[1] ? b._sp = f[1].split(".")[0] + "." + (new Date).getTime() : window.trackerDUID && (b._sp = window.trackerDUID[1] + "." + (new Date).getTime())
            }
            j(b);
            var g, h, i = !1;
            if (!N) {
                if (N = !0, !x()) return void m(a);
                try {
                    g = window.top.location.host
                } catch (a) {}
                try {
                    h = window.frameElement
                } catch (a) {}
                if (d && (b.custom_host = encodeURIComponent(btoa(a))), i = "www.pronto-ny.com" !== window.location.host && (!g || window.location.host !== g || h && !h.hasAttribute("src")), window.self !== window.top && i) return window.top === window.parent && window.document.referrer && (b.site_url = encodeURIComponent(btoa(window.document.referrer))), N = !1, void((F = window.open(a + "api/widget_redirect" + k(b), "ordering")) && F.focus && F.focus());
                o(), B(a + "api/widget_setup" + l(b), function (a, b) {
                    if (a) return N = !1, p(), alert("We could not load the ordering widget. " + (a.toString ? a.toString() : a)), console.error("Could not load widget", a);
                    "desktop" === (c || (b.is_mobile ? "mobile" : "desktop")) ? n(b.url): r(b.url)
                })
            }
            return !1
        }

        function j(a) {
            !a.gclid && I && (a.glfa_cid = I, a.glfa_t = (new Date).getTime())
        }

        function k(a) {
            return w(a, ["company_uid", "restaurant_uid", "restaurant_id", "site_url", "custom_host", "reservation"].concat(E))
        }

        function l(a) {
            return w(a, ["company_uid", "restaurant_uid", "restaurant_id", "custom_host", "ref_tracker", "reservation", "admin_mode", "promotion_test"].concat(E))
        }

        function m(a) {
            var b = window.open(a + "embedder/old_browser.html", "_blank");
            b && b.focus && b.focus(), N = !1
        }

        function n(a) {
            var b = !1,
                c = document.getElementsByTagName("body")[0],
                d = document.createElement("iframe");
            d.setAttribute("id", "gfOrderFrm"), d.setAttribute("frameborder", "0"), d.setAttribute("src", a), d.setAttribute("allowpaymentrequest", !0), d.setAttribute("style", "display: none; z-index: 999998 !important; border: 0 !important; position:fixed !important; top:0 !important; left:0 !important; right:0 !important; bottom:0 !important; width:100% !important; height:100% !important; visibility: visible; opacity: 1;"), d.setAttribute("onmousewheel", ""), setTimeout(function () {
                N = !1
            }, 500), y(d, "load", function () {
                if (!b) {
                    b = !0;
                    var a = d.getAttribute("style");
                    d.setAttribute("style", a.replace("display: none;", "")), p(), N = !1, z(window, "keydown", q)
                }
            }), y(window, "keydown", q), c.appendChild(d), c.style.overflow = "hidden"
        }

        function o() {
            var a = document.getElementsByTagName("body")[0],
                b = document.createElement("div"),
                c = document.createElement("div"),
                d = document.createElement("div");
            b.setAttribute("id", "gfBackdrop"), b.setAttribute("class", "glf-backdrop"), c.setAttribute("class", "glf-preloader-wrapper"), d.setAttribute("class", "glf-preloader"), c.appendChild(d), b.appendChild(c), setTimeout(function () {
                b.setAttribute("class", "glf-backdrop glf-backdrop-visible")
            }, 0), a.appendChild(b)
        }

        function p() {
            var a = document.querySelector(".glf-backdrop");
            a.parentNode.removeChild(a)
        }

        function q(a) {
            if (a = a || window.event, 27 === (a.keyCode || a.which)) return a.preventDefault(), !1
        }

        function r(a) {
            var b, c;
            N = !1;
            try {
                b = !top.document
            } catch (a) {
                b = !0
            }
            c = b ? top : window, p(), c.location.href = a + "&client_is_mobile=true"
        }

        function s() {
            ! function (a, b, c, d, e, f, g) {
                a.GoogleAnalyticsObject = e, a[e] = a[e] || function () {
                    (a[e].q = a[e].q || []).push(arguments)
                }, a[e].l = 1 * new Date, f = b.createElement(c), g = b.getElementsByTagName(c)[0], f.async = 1, f.src = d, g.parentNode.insertBefore(f, g)
            }(window, document, "script", "//www.google-analytics.com/analytics.js", "ga"), ga("create", "UA-43626902-4", "auto", "glfTracker"), ga(function () {
                I = ga.getByName("glfTracker").get("clientId")
            }), "snowplow" === C && function (a, b, c, d, e, f, g) {
                a[e] || (a.GlobalSnowplowNamespace = a.GlobalSnowplowNamespace || [], a.GlobalSnowplowNamespace.push(e), a[e] = function () {
                    (a[e].q = a[e].q || []).push(arguments)
                }, a[e].q = a[e].q || [], f = b.createElement(c), g = b.getElementsByTagName(c)[0], f.async = 1, f.src = d, g.parentNode.insertBefore(f, g))
            }(window, document, "script", "https://www.fbgcdn.com/embedder/js/static/sp.js", "snowplow_legacy")
        }

        function t(a) {
            if ("snowplow" === C && window.snowplow_legacy) {
                window.trackers || (window.trackers = []);
                var b = "prod_legacy_" + a; - 1 == window.trackers.indexOf(a) && (window.snowplow_legacy("newTracker", b, "analytics.fbgcdn.com", {
                    appId: a,
                    post: !1,
                    cookieSameSite: "None",
                    cookieSecure: !0,
                    forceSecureTracker: !0,
                    contexts: {
                        webPage: !0,
                        performanceTiming: !1,
                        gaCookies: !0,
                        geolocation: !1
                    }
                }), window.snowplow_legacy("setUserIdFromLocation", "u"), window.snowplow_legacy("trackPageView:" + b, "/widget/_events/button-view"), window.snowplow_legacy(function () {
                    window.trackerDUID = this[b].getDomainUserInfo()
                }), window.trackers.push(a))
            }
        }

        function u(a) {
            ga("glfTracker.send", "pageview", "/widget/_events/button-view" + a)
        }

        function v(a, b) {
            function c() {
                if (!K) {
                    K = !0;
                    for (var a = 0; a < J.length; a++) J[a].fn.call(window, J[a].ctx);
                    J = []
                }
            }
            if (K) return void setTimeout(function () {
                a(b)
            }, 1);
            J.push({
                fn: a,
                ctx: b
            }), "complete" === document.readyState ? setTimeout(c, 1) : L || (document.addEventListener ? (document.addEventListener("DOMContentLoaded", c, !1), window.addEventListener("load", c, !1)) : (document.attachEvent("onreadystatechange", function () {
                "complete" === document.readyState && c()
            }), window.attachEvent("onload", c)), L = !0)
        }

        function w(a, b) {
            var c, d, e = [];
            for (b = b || ["restaurant_uid", "company_uid", "ref_tracker", "reservation", "restaurant_id"].concat(E), c = 0; c < b.length; c++) d = b[c], a.hasOwnProperty(d) && e.push(d + "=" + a[d]);
            return e.push("timestamp=" + (new Date).getTime()), e.length > 0 ? "?" + e.join("&") : ""
        }

        function x() {
            return "Promise" in window && "isFinite" in Number && "keys" in Array.prototype && "startsWith" in String.prototype && "function" == typeof Object.values
        }

        function y(a, b, c) {
            a.addEventListener ? a.addEventListener(b, c, !1) : a.attachEvent("on" + b, c)
        }

        function z(a, b, c) {
            a.removeEventListener ? a.removeEventListener(b, c, !1) : a.detachEvent("on" + b, c)
        }

        function A(a) {
            for (var b = {
                    strictMode: !1,
                    key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
                    q: {
                        name: "queryKey",
                        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
                    },
                    parser: {
                        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
                        loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
                    }
                }, c = b.parser[b.strictMode ? "strict" : "loose"].exec(a), d = {}, e = 14; e--;) d[b.key[e]] = c[e] || "";
            return d[b.q.name] = {}, d[b.key[12]].replace(b.q.parser, function (a, c, e) {
                c && (d[b.q.name][c] = e)
            }), d
        }

        function B(a, b) {
            function c(a) {
                var b = a.split("/");
                return b[0] + "//" != window.location.protocol + "//" || b[2] === window.location.host
            }
            var d = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"),
                e = function () {
                    b(null, JSON.parse(d.responseText))
                };
            window.XDomainRequest && !c(a) && (d = new XDomainRequest, d.onload = e), d.onerror = b, d.onreadystatechange = function () {
                4 === d.readyState && 200 === d.status && e()
            };
            try {
                "withCredentials" in d ? d.open("GET", a, !0) : d.open("GET", a), d.send(null)
            } catch (a) {
                b(a)
            }
        }
        var C = "snowplow",
            D = "https://www.fbgcdn.com/",
            E = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "gclid", "glfa_cid", "glfa_t", "_sp", "u"];
        b.exports = {
            addButtonHandler: f,
            showGloriaFoodWidget: i,
            openGloriaFoodWidget: h,
            addReadyListener: v,
            addEventListener: y,
            onFrameMessage: d,
            parseUri: A,
            GA_QUERY_PARAM_KEYS: E,
            OPEN_WIDGET_QUERY_PARAM_KEY: "glf_open_widget"
        };
        var F, G = !1,
            H = !1,
            I = !1,
            J = [],
            K = !1,
            L = !1,
            M = !1,
            N = !1
    }, {}],
    2: [function (a, b, c) {
        function d() {
            var a = history.pushState;
            history.pushState = function () {
                a.apply(history, arguments), e()
            }
        }

        function e() {
            setTimeout(f, 0)
        }

        function f(a) {
            var b;
            b = a ? Array.isArray(a) ? a : [a] : [].slice.call(document.querySelectorAll("*[data-glf-cuid]")), b.forEach(function (a) {
                if (!a.__glfAttached) {
                    a.__glfAttached = !0;
                    var b, c, d, e, f, i, j = "glfButton" + h;
                    h++, a.dataset ? (b = a.dataset.glfHost, c = a.dataset.glfCuid, d = a.dataset.glfRuid, e = a.dataset.glfForceMode, f = a.dataset.glfReservation) : (b = a.getAttribute("data-glf-host"), c = a.getAttribute("data-glf-cuid"), d = a.getAttribute("data-glf-ruid"), e = a.getAttribute("data-glf-force-mode"), f = a.getAttribute("data-glf-reservation")), b = b || "https://www.foodbooking.com/", i = {
                        url: b,
                        isCustomUrl: "https://www.foodbooking.com/" !== b,
                        elementIds: [j],
                        companyUID: c,
                        restaurantUID: d,
                        forceMode: e,
                        reservation: f,
                        analytics: []
                    };
                    var k = !1;
                    window.location.search.replace("?", "").split("&").forEach(function (a) {
                        var b = a.split("="),
                            c = b[0],
                            d = b[1];
                        c && d && (-1 === c.indexOf(g.OPEN_WIDGET_QUERY_PARAM_KEY) || "true" !== d || f || (k = !0), g.GA_QUERY_PARAM_KEYS.indexOf(c) >= 0 && i.analytics.push({
                            key: c,
                            value: d
                        }))
                    }), a.setAttribute("id", j), k && window.glfOpenWidget(i), g.addButtonHandler(i)
                }
            })
        }
        if (!window.glfLoaded) {
            window.glfLoaded = !0;
            var g = a("./embed_lib.js"),
                h = 0;
            window.glfWidget = g.addButtonHandler, window.glfOpenWidget = g.openGloriaFoodWidget, window.glfBindButtons = f, g.addReadyListener(f), g.addEventListener(window, "message", g.onFrameMessage), d(), g.addEventListener(window, "popstate", e)
        }
    }, {
        "./embed_lib.js": 1
    }]
}, {}, [2]);
Gewijzigd op 10/05/2021 14:14:53 door - Ariën -
 
PHP hulp

PHP hulp

19/04/2024 21:10:04
 
- Ariën  -
Beheerder

- Ariën -

10/05/2021 13:49:43
Quote Anchor link
Edit:
Kan je je vraag beperken tot relevante code, en deze tussen [code] en [/code] plaatsen? Ook wil ik je vragen een goede titel te bedenken die je probleem/vraagstelling omschrijft.
Alvast bedankt!


Toevoeging op 10/05/2021 14:12:54:

Heb je geen beschikking over de un-minified JavaScript met normale variabelen en commentaar? Want hier zou je niet in mogen/horen werken. Volgens mij is deze code behorend bij de functie je van bij een externe site hebt aangevraagd, en heb je hier geen controle over.

Wat is de relevante code (graag geen hele lappen code) die je op jouw site gebruikt?
Gewijzigd op 10/05/2021 14:16:16 door - Ariën -
 

10/05/2021 14:53:03
Quote Anchor link
Beste Ariën,

Bedankt voor je snelle reactie.
Nee, waarschijnlijk geen beschikking tot de un-minified JavaScript.
Het klopt dat de behorende functie van een externe site is.

Of misschien dat het mogelijk is, dat na het zoeken van de postcode 7607 de button wel weergegeven wordt en automatisch geklikt wordt.

Dit is de code wat ik gebruik voor het zoeken van een postcode.
Eventueel dacht ik erover na dat het ook wel in PHP mag zijn.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


<!--
function Blank_TextField_Validator() {
    // Check the value of the element named text_name from the form named text_form
    if (text_form.text_name.value == "") {
        // If null display and alert box
        alert("U heeft geen postcode gegevens ingevuld.");
        // Place the cursor on the field for revision
        text_form.text_name.focus();
        // return false to stop further processing
        return (false);
    }
    // If text_name is not null continue processing
    if (text_form.text_name.value == "7605")
   document.getElementById("demo").innerHTML = "Postcode 7605";
    else if (text_form.text_name.value == "7607")
   document.getElementById("demo").innerHTML = "Postcode 7607";
  

    else if (text_form.text_name.value == "under")
        window.open('underconstruction.htm');
    else
        alert("Wij bezorgen niet in uw postcode. Franschise nemer worden? Neem contact op.");
    return (false);
}
-->
</script>
 
- Ariën  -
Beheerder

- Ariën -

10/05/2021 17:39:30
Quote Anchor link
Waar en hoe roep je Blank_TextField_Validator() aan?
 

11/05/2021 10:48:45
Quote Anchor link
De functie Blank_TextField_Validator wordt in principe nergens op de pagina gebruikt.
 
- Ariën  -
Beheerder

- Ariën -

11/05/2021 11:02:53
Quote Anchor link
Dus je hebt een procedure waar je niks mee doet....
 

11/05/2021 11:10:11
Quote Anchor link
Sorry, ik bedoelde dat ik verder nergens op de pagina de Blank_TextField_Validator() gebruik.

Natuurlijk gebruik ik de Validator wel voor het zoeken van de postcode.

Maar is het een mogelijkheid om de functies van https://www.fbgcdn.com/embedder/js/ewm2.js daarin in integreren.
 
- Ariën  -
Beheerder

- Ariën -

11/05/2021 11:41:07
Quote Anchor link
Aan de minified-code hoef je niet naar om te kijken. Je kan die niet aanpassen, en het is behoorlijk 'cozy'.
Voor welk doeleinde gebruik je die?
 

11/05/2021 12:36:30
Quote Anchor link
Oke, dit is de bedoeling voor het zoeken op postcode.

https://www.debombv.nl/buitenhaven/

Als je op de website komt is er rechts een textbox voor het invullen van de postcode.

Nu zijn de buttons direct zichtbaar als je de pagina laadt.

Na het zoeken van postcode 7605, is het de bedoeling dat de buttons pas zichtbaar zijn.

Het mooiste zou zijn, dat je een postcode invult en dat het menu direct beschikbaar is.
 
Adoptive Solution

Adoptive Solution

11/05/2021 13:00:36
Quote Anchor link
Verberg de knoppen met css display:none.
Als de postcode voorkomt, toon je de betreffende knop met css display:block
Inspiratie hier :

https://www.w3schools.com/howto/howto_js_toggle_hide_show.asp
 
- Ariën  -
Beheerder

- Ariën -

11/05/2021 13:01:04
Quote Anchor link
Is het niet praktischer om dit via AJAX te doen?
- Een postcode invullen
- Controleren of die geldig is, zo niet: Toon een melding dat je niet levert in dat postcode gebied.
- Zo ja, er vindt een aanroep naar een apart script plaats (postcodecheck.php?postcode=7605)
- Toon alles wat er bij hoort.

Dan hoef je niet hardcoded alle postcodes in je script te plaatsen.
Een kleine edge-case is dat als je straks een postcode gebied erbij hebt, dat klanten nog een oude gecachede JavaScript-code code hebben, en alsnog niet kunnen bestellen tot ze Ctrl+F5 doen.
 

14/05/2021 16:02:24
Quote Anchor link
Ja, nu heb ik het gemaakt met AJAX.
Maar de button zie ik alleen nog niet.
Zoals ik al eerder zei, is het de bedoeling dat de menukaart direct wordt geladen na het invullen van de postcode.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Ajax</title>
<script>
function postComment() {
    // Creating the XMLHttpRequest object
    var request = new XMLHttpRequest();
    
    // Instantiating the request object
    request.open("POST", "confirmation.php");
    
    // Defining event listener for readystatechange event
    request.onreadystatechange = function() {
        // Check if the request is compete and was successful
        if(this.readyState === 4 && this.status === 200) {
            // Inserting the response from server into an HTML element
            document.getElementById("result").innerHTML = this.responseText;
        }
    };
    
    // Retrieving the form data
    var myForm = document.getElementById("myForm");
    var formData = new FormData(myForm);

    // Sending the request to the server
    request.send(formData);
}
</script>
</head>
<body>
    <form id="myForm">
        <label>Postcode:</label>
        <div><input type="text" name="name"></div>
        <p><button type="button" onclick="postComment()">Zoeken</button></p>
    </form>    
    <div id="result">
        <p>Vul hierboven hier uw postcode in 4 cijfers!</p>
    </div>    
</body>
</html>


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = htmlspecialchars(trim($_POST["name"]));
    
    // Check if form fields values are empty
    if(!empty($name == 7606)) {
        echo "<p>Postcode <b>$name</b>Bezorgen wij!.<p>";
         echo "<span class='btn btn-primary btn-block' data-glf-cuid='e81ccf63-7066-46b4-a684-4a69b2383f42' data-glf-ruid='2d28297f-2608-4787-9456-023ff0e90368'  >Bekijk het Menu Chicken Express II</span>
         <script src='https://www.fbgcdn.com/embedder/js/ewm2.js' defer async ></script>"
;
    }
else {
        echo "<p>Deze postcode gebied bezorgen wij niet!</p>";
    }
}
else {
    echo "<p>Probeer opnieuw</p>";
}

?>
Gewijzigd op 14/05/2021 16:02:59 door
 
- Ariën  -
Beheerder

- Ariën -

14/05/2021 16:10:56
Quote Anchor link
Wordt het script wel geladen?
 

14/05/2021 16:12:26
Quote Anchor link
Nee, een voorbeeld heb ik online:

https://www.debombv.nl/buitenhaven/test.php

Toevoeging op 14/05/2021 17:14:02:

Nu toon het script de button wel, maar als ik op de button klikt werkt deze niet.

echo "<input type='button' class='btn btn-primary btn-block' data-glf-cuid='e81ccf63-7066-46b4-a684-4a69b2383f42' data-glf-ruid='2d28297f-2608-4787-9456-023ff0e90368' style='margin-top:5px;' value='Bekijk het Menu Chicken Express II' /><script src='https://www.fbgcdn.com/embedder/js/ewm2.js' defer async ></script>";
 
- Ariën  -
Beheerder

- Ariën -

15/05/2021 10:57:43
Quote Anchor link
Is die button onderdeel van je embedder javascript?
Laad die dan eerst.
 

18/05/2021 10:39:28
Quote Anchor link
Ja, de button is een onderdeel van de embedder javascript.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script src='https://www.fbgcdn.com/embedder/js/ewm2.js' defer async ></script>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = htmlspecialchars(trim($_POST["name"]));
    
    // Check if form fields values are empty
    if(!empty($name == 7606)) {
        echo "<p>Postcode <b>$name</b>Bezorgen wij!.<p>";
        echo"<script src='https://www.fbgcdn.com/embedder/js/ewm2.js' defer async ></script>";
        
         echo "<script src='https://www.fbgcdn.com/embedder/js/ewm2.js' defer async ></script><input type='button' class='btn btn-primary btn-block' data-glf-cuid='e81ccf63-7066-46b4-a684-4a69b2383f42' data-glf-ruid='2d28297f-2608-4787-9456-023ff0e90368' style='margin-top:5px;' value='Bekijk het Menu Chicken Express II' />";
    }
else {
        echo "<p>Deze postcode gebied bezorgen wij niet!</p>";
    }
}
else {
    echo "<p>Something went wrong. Please try again.</p>";
}

?>


Verschillende manieren geprobeerd om het javascript eerder te laden.

Het is ook mogelijk om via een url het menukaart van het restaurant te krijgen.


https://www.foodbooking.com/ordering/restaurant/menu?restaurant_uid=037165d2-e156-4256-973f-ab9fe2607ea9

<script type="text/javascript">

window.open( "/index.php" )
</script>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
echo " <script type='text/javascript'>

window.open( '/index.php' )
</script> ";


De index.php wordt niet geopend. Geen idee waarom PHP niet samen met <script> werkt.
 
- Ariën  -
Beheerder

- Ariën -

18/05/2021 11:02:27
Quote Anchor link
Zet een punt-komma na je window.open() functie.
 

18/05/2021 11:25:41
Quote Anchor link
Geprobeerd met window.open ('/index.php');

Maar dit werkt ook niet.
 
- Ariën  -
Beheerder

- Ariën -

18/05/2021 12:02:47
Quote Anchor link
Die code is correct.
Wordt die Javascript wel ingeladen?
 

18/05/2021 13:09:11
Quote Anchor link
Oke, nee ik denk het niet anders werkte het script wel.

Hoe kan ik weten of de JavaScript wordt ingeladen?

Inspecteren bij de browser?
 
- Ariën  -
Beheerder

- Ariën -

18/05/2021 13:15:59
Quote Anchor link
Klopt.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.