so i've been using the site for answers for a while now but i need some help so here it is.
I have created a bunch of onclick events on buttons using jquery and am using them to dynamically change the css on my site. The problem i'm having is i want the users chosen colours and font size setting to be useds when the page is reloaded or a second page is called.
edit: The chosen background colour is now sent to the url and will hold the value on reload but if i click a second option the first option is disabled and the second is enabled but the first attribute is still shows in the url i need to have at least four possible clicks one for background colour one for font colour one for font size and one for line hieght
any help would me appreciated
These are the buttons
<div id="bc">
Background Colour
<button id="bcyellow">yellow</button>
<button id="bcblue">blue</button>
<button id="bcblack">black</button>
<button id="bcwhite">white</button>
</div>
<div id="tc">
Text Colour
<button id="tcyellow">yellow</button>
<button id="tcblue">blue</button>
<button id="tcblack">black</button>
<button id="tcwhite">white</button>
</div>
<div id="fs">
Font Size
<button id="fsdown">Default</button>
<button id="fsup">Big</button>
</div>
<div id="lh">
Line Height
<button id="lhdown">Default</button>
<button id="lhup">Wide</button>
</div>
this is the jquery
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
$(document).ready(function(){
//change background colour to yellow
$(function(){
$("#bcyellow").click(function(){ window.location = document.URL+"?background-color=yellow"; });
switch(getParameterByName("background-color")){
case "yellow" :
$("body").css("background-color","rgba(247, 233, 107, 1)");
break;
default :
//your default color
break;
}
});
//change background colour to blue
$(function(){
$("#bcblue").click(function(){ window.location = document.URL+"?background-color=blue"; });
switch(getParameterByName("background-color")){
case "blue" :
$("body").css("background-color","rgba(110, 165, 236, 1)");
break;
default :
//your default color
break;
}
});
//change background colour to green
$(function(){
$("#bcgreen").click(function(){ window.location = document.URL+"?background-color=green"; });
switch(getParameterByName("background-color")){
case "green" :
$("body").css("background-color","rgba(156, 255, 174, 1)");
break;
default :
//your default color
break;
}
});
//change background colour to pink
$(function(){
$("#bcpink").click(function(){ window.location = document.URL+"?background-color=pink"; });
switch(getParameterByName("background-color")){
case "pink" :
$("body").css("background-color","rgba(245, 175, 247, 1)");
break;
default :
//your default color
break;
}
});
//change background colour to black
$(function(){
$("#bcblack").click(function(){ window.location = document.URL+"?background-color=black"; });
switch(getParameterByName("background-color")){
case "black" :
$("body").css("background-color","rgba(0, 0, 0, 1)");
break;
default :
//your default color
break;
}
});
//change background colour to white
$(function(){
$("#bcwhite").click(function(){ window.location = document.URL+"?background-color=white"; });
switch(getParameterByName("background-color")){
case "white" :
$("body").css("background-color","rgba(255, 255, 255, 1)");
break;
default :
//your default color
break;
}
});
//change text colour to green
$(function(){
$('#tcgreen').click(function(){ window.location = document.URL+"?color=green"; });
switch(getParameterByName("color")){
case "green" :
$('body').css("color", "rgba(0, 150, 0, 1)") ;
break;
default :
//your default color
break;
}
});
//change text colour to blue
$(function(){
$('#tcblue').click(function(){ window.location = document.URL+"?color=blue"; });
switch(getParameterByName("color")){
case "blue" :
$('body').css("color", "rgba(0, 0, 171, 0.9)");
break;
default :
//your default color
break;
}
});
//change text colour to black
$(function(){
$('#tcblack').click(function(){ window.location = document.URL+"?color=black"; });
switch(getParameterByName("color")){
case "black" :
$('body').css('color', 'rgba(0, 0, 0, 1)');
break;
default :
//your default color
break;
}
});
//change text colour to white
$(function(){
$('#tcwhite').click(function(){ window.location = document.URL+"?color=white"; });
switch(getParameterByName("color")){
case "white" :
$('body').css('color', 'rgba(255, 255, 255, 1)');
break;
default :
//your default color
break;
}
});
//change text size increment
$(function(){
$('#fsup').click(function(){ window.location = document.URL+"?font-size3em"; });
switch(getParameterByName("font-size")){
case "3em" :
$("body").css("font-size","3em");
break;
default :
//your default size
break;
}
});
//reset text size
$(function(){
$('#fsdown').click(function(){ window.location = document.URL+"?font-size=1em"; });
switch(getParameterByName("font-size")){
case "1em" :
$("body").css("font-size","1em");
break;
default :
//your default font-size
break;
}
});
//change line height to wide
$(function(){
$('#lhup').click(function(){ window.location = document.URL+"?line-height=wide"; });
switch(getParameterByName("line-height")){
case "wide" :
$("body").css("line-height","1.5");
break;
default :
//your default line-height
break;
}
});
//reset line height
$(function(){
$('#lhdown').click(function(){ window.location = document.URL+"?line-height=default"; });
switch(getParameterByName("line-height")){
case "default" :
$("body").css("line-height","1");
break;
default :
//your default line-height
break;
}
});
});