JS Not working
-
Hi,
I’m using the below code to get a specfic output where it autofills the input fields “text-3” and “currency-1” according to the valuues of the input “date-1” “date-2” and “radio-1”, but the code doesn’t seem to working, please do resolve me the issue ASAP…
window.addEventListener("DOMContentLoaded", (e) => { const t = document.querySelector("#forminator-field-currency-1"), a = document.querySelector('input[name="date-1"]'), n = document.querySelector('input[name="date-2"]'), r = document.querySelectorAll('input[name="radio-1"]'), o = document.querySelector("#forminator-field-text-3"), u = document.querySelector('input[name="name-1"]'), d = document.querySelector('input[name="name-2"]'), c = document.querySelector("#forminator-field-email-1"), l = document.querySelector("#forminator-field-text-1"), m = document.querySelector("#forminator-field-textarea-1"), s = document.querySelector("#forminator-field-phone-1"), v = document.querySelector("#forminator-field-number-1"), y = document.querySelector("#forminator-field-number-2"), f = document.querySelector("#payhere-payment"); var h; const p = () => { let e = "Car", m = "0.00"; if ("" != a.value && "" != n.value) { for (i = 0; i < r.length; i++) r[i].checked && (e = r[i].value); const t = new Date(a.value), u = new Date(n.value); u.setDate(u.getDate()); const d = u.getTime() - t.getTime(), c = d / 864e5 > 0 ? d / 864e5 : 1; (o.value = 0 == c ? 1 : c), "Car" == e ? (m = 45 * c) : "Van" == e ? (m = 55 * c) : "Bus" == e ? (m = 70 * c); } t.value = m; var p = { start_date: a.value, end_date: n.value, days_diff: o.value }, g = { name: u.value + " " + d.value, adult: v.value, child: y.value, phone: s.value, vehicle: e }; (h = { sandbox: !1, merchant_id: "217544", return_url: void 0, cancel_url: void 0, notify_url: "https://payment.srilankatoursandcars.com/api.php", order_id: "01", items: "Customize Multi Tour", amount: m, currency: "USD", first_name: u.value, last_name: d.value, email: c.value, phone: s.value, address: void 0, city: l.value, country: l.value, custom_1: JSON.stringify(p), custom_2: JSON.stringify(g), }), "" != u.value && "" != d.value && "" != c.value && "" != l.value && "" != s.value && "" != v.value && "" != y.value && "" != a.value && "" != n.value ? (f.disabled = !1) : (f.disabled = !0); }; t && (t.readOnly = !0), o && (o.readOnly = !0), f && (f.disabled = !0), a && a.addEventListener("change", (e) => { p(); }), n && a.addEventListener("change", (e) => { p(); }), m && m.addEventListener("change", (e) => { p(); }), u && u.addEventListener("change", (e) => { p(); }), d && d.addEventListener("change", (e) => { p(); }), c && c.addEventListener("change", (e) => { p(); }), l && l.addEventListener("change", (e) => { p(); }), s && s.addEventListener("change", (e) => { p(); }), v && v.addEventListener("change", (e) => { p(); }), y && y.addEventListener("change", (e) => { p(); }), r && r.forEach((e) => { e.addEventListener("change", (e) => { p(); }); }), (payhere.onCompleted = function (e) { document.querySelector(".forminator-button-submit").click(), alert("Payment completed"); }), (payhere.onDismissed = function () { alert("Payment dismissed"); }), (payhere.onError = function (e) { alert("Error:" + e); }), (document.getElementById("payhere-payment").onclick = function (e) { payhere.startPayment(h); }), (contactpayment = { sandbox: !1, merchant_id: "217544", return_url: void 0, cancel_url: void 0, notify_url: "https://payment.srilankatoursandcars.com/api.php", order_id: "01", items: "Customize Multi Tour", amount: 10, currency: "USD", first_name: "Website", last_name: "contact", email: "info@akasa.lk", phone: "0778786733", address: void 0, city: "srilanka", country: "srilanka", }), (document.getElementById("concheckout").onclick = function (e) { payhere.startPayment(contactpayment); ????????}); });
Thank you,
Regards,
Ssd Server 9The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘JS Not working’ is closed to new replies.