In my web page I have a slider bar, few check boxes, radio buttons etc, which are common across 开发者_高级运维pages. When I navigate from this page I want to preserve the position of the slider bar and other options. How can I acheive it?
Presumably they're part of a form used to gather input — I'd have thought you want to submit this form to a specified action, which you define in your PHP to save the values in a database.
Then when each page loads you query the database for the relevant values and bob's your uncle.
If my answer sounds vague, it's because the question is quite vague — if you're new to web development I think you'll do best to find a good book / tutorial on PHP if that is what you're using.
You could either save the positions and options of the elements in a cookie and set the position of the elements on each page
or you could use an html5 iframe to load the page you are navigating to.
Best approach is using cookies to store the state of the controls you want to keep across page requests, this is perfectly achievable with javascript.
Presuming the contols are form elements:
- listen to the change event of each control
- when a change occurs save the new state in a cookie
- when you (re)load the page check for the existence of a cookie
- When it exists, read it
- restore the state of the control with the data from the cookie
This seems/is very simplistic but should be not to hard to implement.
PPK has a good (vanilla javascript) intro to cookies or if you are using jquery there is the excellent cookie plugin.
精彩评论