I have a form with 5 fieldsets each with Next & Previous buttons. A checking button is added to the last fieldset to check the required fields. After filling up the required fields, I need to add another button in each fieldset to jump direct to the submit fieldset without passing in each fieldset again. Any help to do so? Thank you.
Asked
Active
Viewed 155 times
-1
-
Post some code, otherwise it's hard to help... – Jesper Højer May 24 '16 at 12:31
1 Answers
0
You could try adding IDs to the fieldsets with numbering on them:
<fieldset id="fs_0"></fieldset>
<fieldset id="fs_1"></fieldset>
<fieldset id="fs_2"></fieldset>
<fieldset id="fs_3"></fieldset>
<fieldset id="fs_4"></fieldset>
Then with javascript you can do a loop:
for(var i = 0: i < 4; i++){}
Since you don't need a button on the last fieldset, the for loop has a limit of 4. At the end you can do something like this:
for(var i = 0: i < 4; i++){
var btn = document.createElement('button');//create button
btn.onclick = function(){ jumpToEnd();};//add function to do
btn.innerHTML = 'JUMP';//what will it show
document.getElementById('fs_' + i).appendChild(btn);//append to fieldset
}
EDIT: Syntax

cthefinal
- 79
- 1
-
I have id for each fieldset but without numbers. I tried to use some of your Javascript but it did not work with me. I already have Next-Previous buttons in each fieldset/tab and wanna add extra button in each fieldset to jum to the last fieldset/page. – Hasan Khaleel May 25 '16 at 05:21
-
I used numbering so I could call the fieldsets through the loop. Hmm, interesting. Could you provide some code? I just can't get around what could be happening. – cthefinal May 25 '16 at 12:21