Duplicating dialog box on the same html page won’t work

hope you’re all having a wonderful day.

code on codepen

<dialog></dialog><button></button>
<dialog></dialog><button></button>

I have this code set with its css and javascript to show a dialog by clicking a button to select the site’s language.

When I duplicate this dialog to the site’s footer it doesnt work anymore and when clicking the dialog on the footer it does nothing but the first dialog still works.

I tried adding ids for the javascript code but I didn’t get anything working.