0

I have created a set of themes for my website. I can load a certain theme on selection by user.(supposing on the home page) Example: 1.blue 2.green 3.dark

I have created a function in jquery to establish this change(val); Now i have to move the selected theme to the next page. How to import the selected theme to the next page?

2 Answers2

1

A query string would seem to be the best approach given what little information you've provided:

http://myawesomesite.com?theme=blue

You'd then use something like this to capture the string and apply it:

Get url parameter jquery Or How to Get Query String Values In js

If you want the theme to persist, you'll need to use a cookie or server-side solution to store the data.

Community
  • 1
  • 1
isherwood
  • 58,414
  • 16
  • 114
  • 157
1

It sounds like you have a static website. In order to pass a value to another page, is to use something called Query String.

So, in your JS code on the theme-selection page, do

var selected_theme = $('#selected_theme').val();
window.location = "/next_page/?selected_theme=" + selected_theme;

This will send the selected theme value to the next page.

I hope this makes sense... :)

Yosep Kim
  • 2,931
  • 22
  • 23
  • The theme should change in the next page on click of the page(section). I can change the theme in all the pages but when i move from one page to another i have to retain the selected theme. Can we use cache to do this? – user3616392 May 08 '14 at 13:35
  • You can use sessions or cookies to save such data. – Yosep Kim May 09 '14 at 00:04