Next Button calls wrong database

Anyone who can help it would be appreciated. I have followed the directions in the tutorials and in fact have a working database on my site for combat scenarios. However, after building another db for unit dossier, the next button calls the Scenarios database. I cant identify the error anywhere because the code looks correct.

Hi,

Could you please share a link to your site editor so we could look into furter

Thanks

Here it is but I have resolved THIS issue BUT… the new issue is that for the Austrianunits database, the forward and back buttons dont work even though my code looks right. There’s got to be something wrong but I cant see it. I’m pretty sure you’ll spot it right away so this former Motorolan will be a little embarrassed but man, I cant see it.

Looks like you forgot to connect the button to data and have it link to next item.

In the editor, select the dynamic page for editing.
Click on the “next” button to select it, on the pop-up menu click on the most right icon (“connect to data”).
In the opened menu select the relevant dataset and under “Links connects to” select “next item”.
Do the same for your previous button as well.

Let me know if that fixed the issue.

fails. When I do as you say, it grays out the button. Also, the process for using buttons the way you say is not what the tutorial said. Also, in my other database, my next button does NOT have a link to Next as you say to do, and that db works.

AHA… SPECIAL NOTICE!!! I suspected something was very wrong with either the cache or other OR it was a backend refresh. So here is how I fixed it. Put this is your help files for other users re: “Button Doesnt Work in Database Item Page.”
I created and dropped onto the page, a new dataset. Linked the buttons to it (not the link as you suggested in the dialog gui). Then deleted it from the page; warning popped up, ignored it. Repeat the process. Add new dataset, delete. Published page after reconnecting buttons back to original. THEN returned the situation to the beginning as if I did not ever contact you. Published. WORKS.

Conclusion: There appears to be a refresh issue possibly cache possibly other in the backend of Wix database; the code for passing info was not getting pushed/refreshed… at least that is my guess. SO THE FACT IS… the thing now works as if I had never contacted you. The button thing you mentioned above is wrong; not what the tutorial says to do.

new information; I was wrong. Buttons are working only in PREVIEW mode, NOT in published site. Again, working in PREVIEW mode only that is, clicking on the item on the page works, but not in published site.

RESOLVED. Typeo in the code; an extra empty line at the end of the pasted code (as learned from the tutorial) was resolved by comparing the working db to this austrianunits db that was not working, and the comparison showed the errors. Surprised that the code self checker didnt catch it.

If anyone can have a look here let me know if this code is the problem:

I just noticed in another db I have, that the next button is doing the same thing: going to a different database (when it reaches the end of records maybe?) Let me know if this code is the culprit:

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(); 
} 

}
} );
{
if($w(“#uploadButton1”).value.length > 0) {
$w(“#text1”).text = Uploading ${$w("#uploadButton1").value[0].name};
$w(“#uploadButton1”).startUpload()
.then( (uploadedFile) => {
$w(“#text1”).text = “Upload successful”;
$w(“#image1”).src = uploadedFile.url;
})
.catch( (uploadError) => {
$w(“#text1”).text = “File upload error”;
console.log(Error: ${uploadError.errorCode});
console.log(uploadError.errorDescription);
});
}
else {
$w(“#text1”).text = “Please choose a file to upload.”;
}
}

here is the editor page in question

New information: Upon first visiting the page without loading anything else, the above issue was experienced. Thereafter, the nuance goes away and the next button works correctly. I do not know why on first visit to the db page that pressing the next button would goto another db page, but it did. I thought maybe it might be because it reached the end of the records but no thats not it either. I will exit browser (Chrome) and try to experience again.

New information: the nuance of the next button has disappeared with nothing to do with browser restart. All I can say is that this morning when I went to the Combat Command Unit Database and called the page (clicked the item entry in the menu), it loaded Brad Pitt’s unit by default (why is that btw? why doesn’t it load the first unit e.g. ID #1 in the db? Brad’s unit is not #1 in the db) then when pressing Next the page that came up was the Napoleonic’s French Units database. How could this happen?