Skip to content

Commit 427c02e

Browse files
REOLVE THE DYNAMIC SUBMIT BUTTON CALLING FUNCTION.
1 parent 1e9481a commit 427c02e

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

app/static/js/service_requests.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ currentRequestId = requestId;
121121
const table = document.getElementById("dynamic_table");
122122
const container = document.getElementById("request_form_container");
123123
const fields = document.getElementById("dynamic_form_fields");
124+
const button = document.getElementById("dynamic_submit_button");
124125

125126
table.classList.add("hidden");
126127
container.classList.remove("hidden");
@@ -135,24 +136,19 @@ fields.innerHTML = `
135136
<input type="password" id="new_pin" placeholder=" " class="peer w-full bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-2xl px-5 pt-7 pb-3 focus:ring-2 focus:ring-cyan-500 focus:border-transparent outline-none transition-all font-medium">
136137
<label class="absolute left-5 top-2.5 text-gray-500 dark:text-gray-400 text-xs font-semibold uppercase tracking-wider transition-all peer-placeholder-shown:top-4 peer-placeholder-shown:text-sm peer-placeholder-shown:normal-case peer-placeholder-shown:tracking-normal peer-focus:top-2.5 peer-focus:text-xs peer-focus:uppercase peer-focus:tracking-wider peer-focus:text-cyan-500">New PIN</label>
137138
<button type="button" id="toggleIcon" onclick="togglePin()" class="absolute right-5 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xl">👁️</button>
138-
<button
139-
onclick="submitRequest('CHANGE_PIN')" class="mt-2 bg-blue-900 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
140-
Submit
141-
</button>
142139
`;
143140

141+
button.onclick("submitRequest('CHANGE_PIN')");
142+
144143
break;
145144

146145
case "CHANGE_ACCOUNT_NAME":
147146

148147
fields.innerHTML = `
149148
<input type="text" id="new_name" class="peer w-full bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-2xl px-5 pt-7 pb-3 focus:ring-2 focus:ring-cyan-500 focus:border-transparent outline-none transition-all font-medium">
150149
<label class="absolute left-5 top-2.5 text-gray-500 dark:text-gray-400 text-xs font-semibold uppercase tracking-wider transition-all peer-placeholder-shown:top-4 peer-placeholder-shown:text-sm peer-placeholder-shown:normal-case peer-placeholder-shown:tracking-normal peer-focus:top-2.5 peer-focus:text-xs peer-focus:uppercase peer-focus:tracking-wider peer-focus:text-cyan-500">New Account Name</label>
151-
<button
152-
onclick="submitRequest('CHANGE_ACCOUNT_NAME')" class="mt-2 bg-blue-900 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
153-
Submit
154-
</button>
155150
`;
151+
button.onclick("submitRequest('CHANGE_ACCOUNT_NAME')");
156152

157153
break;
158154

app/templates/service_requests.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ <h2 class="text-3xl font-extrabold text-gray-900 dark:text-white mb-2">Complete
289289
</div>
290290
<form class="flex flex-col gap-5">
291291
<div id="dynamic_form_fields" class="relative group"></div>
292+
<button id="dynamic_submit_button" class="btn-glow w-full bg-gradient-to-r from-blue-600 to-cyan-500 text-white py-4 rounded-2xl font-bold text-lg hover:from-blue-700 hover:to-cyan-600 active:scale-[0.98] transition-all duration-200 shadow-md flex items-center justify-center gap-2 mt-2">
293+
<span id="btnText">Submit →</span>
294+
<svg id="spinner" class="hidden w-5 h-5 animate-spin" viewBox="0 0 24 24">
295+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4">
296+
</circle>
297+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 00-4 4H4z"></path>
298+
</svg>
299+
</button>
292300
<button onclick="location.reload()" class="btn-glow w-full bg-gradient-to-r from-blue-600 to-cyan-500 text-white py-4 rounded-2xl font-bold text-lg hover:from-blue-700 hover:to-cyan-600 active:scale-[0.98] transition-all duration-200 shadow-md flex items-center justify-center gap-2 mt-2">
293301
<span id="btnText">Cancel →</span>
294302
<svg id="spinner" class="hidden w-5 h-5 animate-spin" viewBox="0 0 24 24">

0 commit comments

Comments
 (0)