Next button on dynamic page only works x times

Sorry about that!

For https://shellmanscandinavia.wixsite.com/website-1/freeform/

import { local } from ‘wix-storage’ ;

const linkField = “link-freeform-title” ; // replace this value

$w . onReady ( function () {
$w ( “#dynamicDataset” ). onReady (() => {
const numberOfItems = $w ( “#dynamicDataset” ). getTotalCount ();

$w ( "#dynamicDataset" ). getItems ( 0 ,  numberOfItems ) 
  . then ( ( result ) => {  
    const  dynamicPageURLs  =  result . items . map ( item  =>  item [ linkField ]); 
    local . setItem ( 'dynamicPageURLs' ,  dynamicPageURLs ); 
  } ) 
  . catch ( ( err ) => { 
    console . log ( err . code ,  err . message ); 
  } ); 

} );
} );

And for item page https://shellmanscandinavia.wixsite.com/website-1/freeform/maldiva

import { local } from ‘wix-storage’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {
$w ( “#previous” ). disable ();
$w ( “#next” ). disable ();

if ( local . getItem ( ‘dynamicPageURLs’ )) {
const dynamicPageURLs = local . getItem ( ‘dynamicPageURLs’ ). split ( ‘,’ );

const  currentPage  =  '/'  +  wixLocation . prefix  +  '/'  +  wixLocation . path . join ( '/' ); 
const  currentPageIndex  =  dynamicPageURLs . indexOf ( currentPage ); 

if  ( currentPageIndex  >  0 ) { 
  $w ( "#previous" ). link  =  dynamicPageURLs [ currentPageIndex  -  1 ]; 
  $w ( "#previous" ). enable (); 
} 

if  ( currentPageIndex  <  dynamicPageURLs . length  -  1 ) { 
  $w ( "#next" ). link  =  dynamicPageURLs [ currentPageIndex  +  1 ]; 
  $w ( "#next" ). enable (); 
} 

}
} );

For https://shellmanscandinavia.wixsite.com/website-1/available Index

import { local } from ‘wix-storage’ ;

const linkField = “link-available-title” ; // replace this value

$w . onReady ( function () {
$w ( “#dynamicDataset” ). onReady (() => {
const numberOfItems = $w ( “#dynamicDataset” ). getTotalCount ();

$w ( "#dynamicDataset" ). getItems ( 0 ,  numberOfItems ) 
  . then ( ( result ) => {  
    const  dynamicPageURLs  =  result . items . map ( item  =>  item [ linkField ]); 
    local . setItem ( 'dynamicPageURLs' ,  dynamicPageURLs ); 
  } ) 
  . catch ( ( err ) => { 
    console . log ( err . code ,  err . message ); 
  } ); 

} );
} );

and title page

import { local } from ‘wix-storage’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {
$w ( “#previous” ). disable ();
$w ( “#next” ). disable ();

if ( local . getItem ( ‘dynamicPageURLs’ )) {
const dynamicPageURLs = local . getItem ( ‘dynamicPageURLs’ ). split ( ‘,’ );

const  currentPage  =  '/'  +  wixLocation . prefix  +  '/'  +  wixLocation . path . join ( '/' ); 
const  currentPageIndex  =  dynamicPageURLs . indexOf ( currentPage ); 

if  ( currentPageIndex  >  0 ) { 
  $w ( "#previous" ). link  =  dynamicPageURLs [ currentPageIndex  -  1 ]; 
  $w ( "#previous" ). enable (); 
} 

if  ( currentPageIndex  <  dynamicPageURLs . length  -  1 ) { 
  $w ( "#next" ). link  =  dynamicPageURLs [ currentPageIndex  +  1 ]; 
  $w ( "#next" ). enable (); 
} 

}
} );

Do i need to store things in different data sets to be able to use it on different parts of the website? in stead of every index page using #dynamicDataset.