-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
59 lines (50 loc) · 1.67 KB
/
script.js
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
// Assuming you have a variable to store the current form section
let current_fs, next_fs, previous_fs;
let opacity;
// Function to show the next form section
function nextForm() {
current_fs = $(this).parent();
next_fs = $(this).parent().next();
// Add class 'active' to the next form section for styling purposes
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
// Show the next form section
next_fs.show();
// Hide the current form section
current_fs.animate({ opacity: 0 }, {
step: function (now, mx) {
// Increase the opacity of the next form section as the current one fades out
opacity = 1 - now;
current_fs.css({
'display': 'none',
'position': 'relative'
});
next_fs.css({ 'opacity': opacity });
},
duration: 600
});
}
// Function to show the previous form section
function previousForm() {
current_fs = $(this).parent();
previous_fs = $(this).parent().prev();
// Remove 'active' class from the current step in the progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
// Show the previous form section
previous_fs.show();
// Hide the current form section
current_fs.animate({ opacity: 0 }, {
step: function (now, mx) {
// Increase the opacity of the previous form section as the current one fades out
opacity = 1 - now;
current_fs.css({
'display': 'none',
'position': 'relative'
});
previous_fs.css({ 'opacity': opacity });
},
duration: 600
});
}
// Attach click event handlers to the 'Next' and 'Previous' buttons
$(".next").click(nextForm);
$(".previous").click(previousForm);