So i have a sepereate page, where the user can click a button to change the style sheet of the website, which will change all the style sheets of each page to the one they have chosen.
External Javascript file:
function ChangeSheet(sheet)
{
document.getElementById('pagestyle').setAttribute('href', sheet);
}
pages = {
default : 0;
design1 : 0;
design2 : 0;
}
function setDefault(var num){
pages.default = num;
}
Html Code for when user clicks the button to change css:
<p>Click one of the links to change the website design viewing settings.</p>
<button onclick="setDefault(1)">Default</button>
Number 1 is saved within pages class, meaning that the user picked this one. basically a bool.
Embedded Javascript in html file, this shows the link id, as well importing the external javascript file. I then try to use internel js to check if pages.deafult is 1, if so, then we change to stylesheet 'design1.css':
<link id = "pagestyle" rel="stylesheet" type="text/css" href="default.css">
<script src= "swap.js"></script>
<script type="text/javascript">
if(pages.default == 1)
{
ChangeSheet('design1.css');
}
</script>
However when i press the button, nothing happens, and im not sure why? Sorry if im not supposed to ask this, i'm very new to website design and javascript.